to authenticate in gcp
1gcloud container clusters get-credentials cluster-1 --zone=us-central1-c
you can create an object declaratively for example when you have a yaml that looks like this
1apiVersion: v12kind: Pod3metadata:4 name: nginx5spec:6 containers:7 - name: nginx8 image: nginx9 ports:10 - name: web11 containerPort: 80
you can do when the name of the file is nginx.yaml
1kubectl apply -f nginx.yaml
creates a tunel for the port exposed from our pod to our shell so we can access it locally
1kubectl port-forward
eg nginx exposes port 80 and we map it to our local shell on 8080 so we can preview it.
1kubectl port-forward nginx 8080:80
you can delete object we created declaratively
1kubectl delete -f nginx.yaml
a yaml example of running multiple containers in the same pod
1apiVersion: v12kind: Pod3metadata:4 name: multi5spec:6 volumes:7 - name: shared-data8 emptyDir: {}9 containers:10 - name: web-container11 image: nginx12 volumeMounts:13 - mountPath: /usr/share/nginx/html14 name: shared-data15 ports:16 - name: web17 containerPort: 8018 - name: ftp-container19 image: fauria/vsftpd20 volumeMounts:21 - mountPath: /pod-data22 name: shared-data
here you can connect to the container using the command
1kubectl exec -it multi -c ftp-container -- /bin/bash
see details of a deployment
1kubectl describe deploymemt {nameofdeployment}
update an existing deployment
1kubectl apply -f {nameOfTheDeployent.yaml} --record
to see the status of our deployment. Note: nameOfDeployment is not the yaml file. Each deployment has a specific name
1kubectl rollout status {nameOfDeployment}
to undo a deployment. Note: nameOfDeployment is not the yaml file. Each deployment has a specific name
1kubectl rollout undo {{nameOfDeployment} }