Navigate back to the homepage

kubctl course and notes

Christos Paschalidis
October 26th, 2021 · 1 min read

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: v1
2kind: Pod
3metadata:
4 name: nginx
5spec:
6 containers:
7 - name: nginx
8 image: nginx
9 ports:
10 - name: web
11 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: v1
2kind: Pod
3metadata:
4 name: multi
5spec:
6 volumes:
7 - name: shared-data
8 emptyDir: {}
9 containers:
10 - name: web-container
11 image: nginx
12 volumeMounts:
13 - mountPath: /usr/share/nginx/html
14 name: shared-data
15 ports:
16 - name: web
17 containerPort: 80
18 - name: ftp-container
19 image: fauria/vsftpd
20 volumeMounts:
21 - mountPath: /pod-data
22 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} }

More articles from blog for tech

Notes on accessible design systems

A note on how to get peers on boarded on accessibility

June 19th, 2021 · 1 min read

learning docker - day 6

Swarm lifecycle

January 3rd, 2021 · 1 min read
© 2020–2021 blog for tech
Link to $https://github.com/paschalidiLink to $https://www.linkedin.com/in/christos-paschalidis/