Skip to content

Commit

Permalink
Adding side modules
Browse files Browse the repository at this point in the history
  • Loading branch information
jbris committed Dec 12, 2023
1 parent 0fb1674 commit b02ef17
Show file tree
Hide file tree
Showing 31 changed files with 550 additions and 0 deletions.
23 changes: 23 additions & 0 deletions config/config_maps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env bash

mkdir -p configure-pod-container/configmap/

wget https://kubernetes.io/examples/configmap/game.properties -O configure-pod-container/configmap/game.properties
wget https://kubernetes.io/examples/configmap/ui.properties -O configure-pod-container/configmap/ui.properties

kubectl create configmap game-config --from-file=configure-pod-container/configmap/

kubectl describe configmaps game-config

kubectl get configmaps game-config -o yaml

kubectl create configmap game-config-2 --from-file=configure-pod-container/configmap/game.properties

kubectl create configmap game-config-2 --from-file=configure-pod-container/configmap/game.properties --from-file=configure-pod-container/configmap/ui.properties

kubectl create configmap game-config-env-file \
--from-env-file=configure-pod-container/configmap/game-env-file.properties

kubectl get configmap config-multi-env-files -o yaml

kubectl apply -k .
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
enemies=aliens
lives=3
allowed="true"

# This comment and the empty line above it are ignored
7 changes: 7 additions & 0 deletions config/configure-pod-container/configmap/game.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
enemies=aliens
lives=3
enemies.cheat=true
enemies.cheat.level=noGoodRotten
secret.code.passphrase=UUDDLRLRBABAS
secret.code.allowed=true
secret.code.lives=30
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
color=purple
textmode=true
how=fairlyNice
4 changes: 4 additions & 0 deletions config/configure-pod-container/configmap/ui.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
color.good=purple
color.bad=yellow
allow.textmode=true
how.nice.to.look=fairlyNice
7 changes: 7 additions & 0 deletions config/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
configMapGenerator:
- name: game-config-4
options:
labels:
game-config: config-4
files:
- configure-pod-container/configmap/game.properties
4 changes: 4 additions & 0 deletions config/secret.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

kubectl create secret generic empty-secret
kubectl get secret empty-secret
8 changes: 8 additions & 0 deletions config/secret/dockercfg-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: Secret
metadata:
name: secret-dockercfg
type: kubernetes.io/dockercfg
data:
.dockercfg: |
eyJhdXRocyI6eyJodHRwczovL2V4YW1wbGUvdjEvIjp7ImF1dGgiOiJvcGVuc2VzYW1lIn19fQo=
27 changes: 27 additions & 0 deletions config/secret/dotfile-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
apiVersion: v1
kind: Secret
metadata:
name: dotfile-secret
data:
.secret-file: dmFsdWUtMg0KDQo=
---
apiVersion: v1
kind: Pod
metadata:
name: secret-dotfiles-pod
spec:
volumes:
- name: secret-volume
secret:
secretName: dotfile-secret
containers:
- name: dotfile-test-container
image: registry.k8s.io/busybox
command:
- ls
- "-l"
- "/etc/secret-volume"
volumeMounts:
- name: secret-volume
readOnly: true
mountPath: "/etc/secret-volume"
17 changes: 17 additions & 0 deletions config/secret/optional-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
containers:
- name: mypod
image: redis
volumeMounts:
- name: foo
mountPath: "/etc/foo"
readOnly: true
volumes:
- name: foo
secret:
secretName: mysecret
optional: true
9 changes: 9 additions & 0 deletions config/secret/serviceaccount-token-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: v1
kind: Secret
metadata:
name: secret-sa-sample
annotations:
kubernetes.io/service-account.name: "sa-name"
type: kubernetes.io/service-account-token
data:
extra: YmFyCg==
17 changes: 17 additions & 0 deletions external_ip/init_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

kubectl apply -f service/load-balancer-example.yaml

kubectl get deployments hello-world
kubectl describe deployments hello-world

kubectl get replicasets
kubectl describe replicasets

kubectl expose deployment hello-world --type=LoadBalancer --name=my-service

kubectl get services my-service

kubectl describe services my-service

kubectl get pods --output=wide
21 changes: 21 additions & 0 deletions external_ip/service/load-balancer-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app.kubernetes.io/name: load-balancer-example
name: hello-world
spec:
replicas: 5
selector:
matchLabels:
app.kubernetes.io/name: load-balancer-example
template:
metadata:
labels:
app.kubernetes.io/name: load-balancer-example
spec:
containers:
- image: gcr.io/google-samples/node-hello:1.0
name: hello-world
ports:
- containerPort: 8080
29 changes: 29 additions & 0 deletions php_redis/application/guestbook/frontend-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# SOURCE: https://cloud.google.com/kubernetes-engine/docs/tutorials/guestbook
apiVersion: apps/v1
kind: Deployment
metadata:
name: frontend
spec:
replicas: 3
selector:
matchLabels:
app: guestbook
tier: frontend
template:
metadata:
labels:
app: guestbook
tier: frontend
spec:
containers:
- name: php-redis
image: gcr.io/google_samples/gb-frontend:v5
env:
- name: GET_HOSTS_FROM
value: "dns"
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 80
19 changes: 19 additions & 0 deletions php_redis/application/guestbook/frontend-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# SOURCE: https://cloud.google.com/kubernetes-engine/docs/tutorials/guestbook
apiVersion: v1
kind: Service
metadata:
name: frontend
labels:
app: guestbook
tier: frontend
spec:
# if your cluster supports it, uncomment the following to automatically create
# an external load-balanced IP for the frontend service.
# type: LoadBalancer
#type: LoadBalancer
ports:
# the port that this service should serve on
- port: 80
selector:
app: guestbook
tier: frontend
30 changes: 30 additions & 0 deletions php_redis/application/guestbook/redis-follower-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SOURCE: https://cloud.google.com/kubernetes-engine/docs/tutorials/guestbook
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-follower
labels:
app: redis
role: follower
tier: backend
spec:
replicas: 2
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
role: follower
tier: backend
spec:
containers:
- name: follower
image: gcr.io/google_samples/gb-redis-follower:v2
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 6379
17 changes: 17 additions & 0 deletions php_redis/application/guestbook/redis-follower-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SOURCE: https://cloud.google.com/kubernetes-engine/docs/tutorials/guestbook
apiVersion: v1
kind: Service
metadata:
name: redis-follower
labels:
app: redis
role: follower
tier: backend
spec:
ports:
# the port that this service should serve on
- port: 6379
selector:
app: redis
role: follower
tier: backend
30 changes: 30 additions & 0 deletions php_redis/application/guestbook/redis-leader-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# SOURCE: https://cloud.google.com/kubernetes-engine/docs/tutorials/guestbook
apiVersion: apps/v1
kind: Deployment
metadata:
name: redis-leader
labels:
app: redis
role: leader
tier: backend
spec:
replicas: 1
selector:
matchLabels:
app: redis
template:
metadata:
labels:
app: redis
role: leader
tier: backend
spec:
containers:
- name: leader
image: "docker.io/redis:6.0.5"
resources:
requests:
cpu: 100m
memory: 100Mi
ports:
- containerPort: 6379
17 changes: 17 additions & 0 deletions php_redis/application/guestbook/redis-leader-service.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# SOURCE: https://cloud.google.com/kubernetes-engine/docs/tutorials/guestbook
apiVersion: v1
kind: Service
metadata:
name: redis-leader
labels:
app: redis
role: leader
tier: backend
spec:
ports:
- port: 6379
targetPort: 6379
selector:
app: redis
role: leader
tier: backend
25 changes: 25 additions & 0 deletions php_redis/init_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/usr/bin/env bash

kubectl apply -f application/guestbook/redis-leader-deployment.yaml

kubectl apply -f application/guestbook/redis-leader-service.yaml

kubectl apply -f application/guestbook/redis-follower-deployment.yaml

kubectl apply -f application/guestbook/redis-follower-service.yaml

kubectl apply -f application/guestbook/frontend-deployment.yaml

kubectl apply -f application/guestbook/frontend-service.yaml

kubectl get pods -l app=guestbook -l tier=frontend

kubectl get pods

# kubectl logs -f deployment/redis-leader

kubectl port-forward svc/frontend 8080:80

kubectl get service

kubectl get service frontend
3 changes: 3 additions & 0 deletions php_redis/scale_app.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash

kubectl scale deployment frontend --replicas=5
5 changes: 5 additions & 0 deletions redis/init_redis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/usr/bin/env bash

kubectl apply -f example-redis-config.yaml

kubectl apply -f https://raw.githubusercontent.com/kubernetes/website/main/content/en/examples/pods/config/redis-pod.yaml
7 changes: 7 additions & 0 deletions redis/kubectl_clean.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/usr/bin/env bash

kubectl delete pod/redis configmap/example-redis-config

kubectl delete pod redis

kubectl delete pod/redis configmap/example-redis-config
11 changes: 11 additions & 0 deletions redis/kubectl_get.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env bash

kubectl get pod/redis configmap/example-redis-config

kubectl describe configmap/example-redis-config

kubectl exec -it redis -- redis-cli

# CONFIG GET maxmemory

kubectl apply -f pods/config/example-redis-config.yaml
8 changes: 8 additions & 0 deletions redis/pods/config/example-redis-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: example-redis-config
data:
redis-config: |
maxmemory 2mb
maxmemory-policy allkeys-lru
Loading

0 comments on commit b02ef17

Please sign in to comment.