Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in controller.sh #35

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions chapter-02/controller.sh
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@

#!/usr/bin/env bash

kubectl get --watch --output-watch-events configmap \
-o=custom-columns=type:type,name:object.metadata.name \
--no-headers | \
while read next; do #B

NAME=$(echo $next | cut -d' ' -f2) #C
while read next; do
NAME=$(echo $next | cut -d' ' -f2 | tr '.' '-') # Replace '.' with '-'
EVENT=$(echo $next | cut -d' ' -f1)

case $EVENT in
ADDED|MODIFIED) #D
ADDED|MODIFIED)
kubectl apply -f - << EOF
apiVersion: apps/v1
kind: Deployment
Expand All @@ -36,8 +34,9 @@ spec:
name: $NAME
EOF
;;
DELETED) #E
DELETED)
kubectl delete deploy $NAME
;;
esac
done

2 changes: 1 addition & 1 deletion chapter-02/declarative-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: nginx-declarative
annotations:
environment: prod
organization: sales
organization: marketing
spec:
replicas: 3
selector:
Expand Down
4 changes: 4 additions & 0 deletions chapter-02/imperative.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
kubectl create deployment nginx-imperative --image=nginx:latest
kubectl scale deployment/nginx-imperative --replicas 3
kubectl annotate deployment/nginx-imperative environment=prod
kubectl annotate deployment/nginx-imperative organization=sales