Skip to content

Commit

Permalink
Upgrade cluster scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitmaji committed Sep 21, 2022
1 parent fcfcf90 commit ed50a12
Showing 1 changed file with 78 additions and 3 deletions.
81 changes: 78 additions & 3 deletions install_k8s/gok
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,68 @@ source "$WORKING_DIR"/config
release=$2
CMD=$1

createApp1() {
cat <<EOF | kubectl apply -f -
apiVersion: apps/v1
kind: Deployment
metadata:
name: app1
namespace: default
spec:
replicas: 1
selector:
matchLabels:
app: app1
template:
metadata:
labels:
app: app1
spec:
containers:
- name: app1
image: dockersamples/static-site
env:
- name: AUTHOR
value: app1
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: appsvc1
namespace: default
spec:
ports:
- port: 80
protocol: TCP
targetPort: 80
selector:
app: app1
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
kubernetes.io/ingress.class: "nginx"
name: app-ingress
namespace: default
spec:
rules:
- host: master.cloud.com
http:
paths:
- backend:
service:
name: appsvc1
port:
number: 80
path: /app1
pathType: Prefix
EOF
}

getpod() {
pod=$(kubectl get po -l app="$release" 2>/dev/null | awk "/${release}/" | awk '{print $1}' | head -n 1)
echo "$pod"
Expand Down Expand Up @@ -44,7 +106,7 @@ ingressInst() {
--set controller.service.nodePorts.http=32001 \
--set controller.service.nodePorts.https=32000 \
--set controller.service.type=NodePort
# -f charts/values.yaml
# -f charts/values.yaml

output=$(kubectl get po -n ingress-nginx -l app.kubernetes.io/component=controller -ojsonpath='{.items[0].status.containerStatuses[0].ready}')
while [ "$output" != "true" ]; do
Expand Down Expand Up @@ -301,7 +363,7 @@ elif [ "$CMD" == "install" ]; then
if [ "$COMPONENT" == "docker" ]; then
dockrInst
elif [ "$COMPONENT" == "ingress" ]; then
ingressInst
ingressInst
elif [ "$COMPONENT" == "kubernetes" ]; then
dockrInst
haInst
Expand Down Expand Up @@ -335,6 +397,19 @@ elif [ "$CMD" == "reset" ]; then
yes
EOF
elif [ "$COMPONENT" == "ingress" ]; then
ingressUnInst
ingressUnInst
fi
elif [ "$CMD" == "deploy" ]; then
COMPONENT=$2
if [ "$COMPONENT" == "app1" ]; then
createApp1
fi
elif [ "$CMD" == "patch" ]; then
RESOURCE=$2
NAME=$3
if [ "$RESOURCE" == "ingress" ]; then
kubectl patch ing $ING --type=json -p='[{"op": "add", "path": "/metadata/annotations", "value":{"certmanager.k8s.io/cluster-issuer": "letsencrypt-prod", "nginx.ingress.kubernetes.io/ssl-redirect": "\"true\""}]' -n $NS
kubectl patch ing $ING --type=json -p='[{"op": "replace", "path": "/spec/rules/0/host", "value":"kube.gokcloud.co.in"}]' -n $NS

fi
fi

0 comments on commit ed50a12

Please sign in to comment.