0% found this document useful (0 votes)
2 views

kubeadm-commands

The document provides commands and YAML configurations for managing Kubernetes Deployments and Services, including creating a Deployment for an Nginx application and exposing it via a NodePort service. It also covers managing ReplicaSets, including creation, scaling, and rolling updates, as well as rollback procedures. Additional commands for initializing a Kubernetes cluster and disabling swap are mentioned.

Uploaded by

rajagopal gajula
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

kubeadm-commands

The document provides commands and YAML configurations for managing Kubernetes Deployments and Services, including creating a Deployment for an Nginx application and exposing it via a NodePort service. It also covers managing ReplicaSets, including creation, scaling, and rolling updates, as well as rollback procedures. Additional commands for initializing a Kubernetes cluster and disabling swap are mentioned.

Uploaded by

rajagopal gajula
Copyright
© © All Rights Reserved
Available Formats
Download as RTF, PDF, TXT or read online on Scribd
You are on page 1/ 3

kubectl get pods --all-namespaces (to check runnint pods)

Here's an example .yaml file that shows the required fields and object spec for a
Kubernetes Deployment:
application/deployment.yaml

apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2


kind: Deployment
metadata:
name: nginx-deployment
spec:
selector:
matchLabels:
app: nginx
replicas: 2 # tells deployment to run 2 pods matching the template
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80

kubectl create service nodeport nginx --tcp=80:80

servicefile.yml
apiVersion: v1

kind: Service

metadata:

name: my-service

spec:

selector:
app: nginx

type: NodePort

ports:

- protocol: TCP

nodePort: 31000

port: 80

targetPort: 80

https://kubernetes.io/docs/tasks/configure-pod-container/

kubectl create service nodeport nginx --tcp=80:80

--------------------------------------------------------------------------------

Replicationsets:

Kubectl create -f replicaset-definition.yml

kubectl get replicaset

kubectl delete replicaset myapp-replicaset

kubectl replace -f replicaset-definition.yml

kubectl scale --replicas=6 -f replicaset-definition.yml

Deployment:

Rollout - new deployment with revision1, if update the image then its Revision2

kubectl rollout status deployment/myapp-deployment

DS -

Recreate - Destroy all and create new instances (Application will go down)
Rolling Update - one after one

kubectl apply -f deployment-definition.yml

Rollback:

kubectl rollout undo deployment/myapp-deployment

https://kubernetes.io/docs/tasks/configure-pod-container/assign-pods-nodes/ (to specify nodes )

kubectl run nginx --image=nginx --port=80 deployment "nginx" created

sudo swapoff -a

sudo sed -i '/ swap / s/^/#/' /etc/fstab

# Reboot a machine after that.

kubeadm reset

kubeadm init --ignore-preflight-errors all

You might also like