Kubernetes Commands
Kubernetes Commands
# kubectl describe rc replication controller name -- it will show all the details of replicatin controller
# kubectl exec -it podname -- /bin/bash -- to enter into pod(it =intractive it vunnapude /bin/bash
vuntundhi ante pod bash shell tho intract avuthundhi)
# kubectl exec <pod name> date --to print date from running container without interring into pod
# kubectl exec <pod name> -c <container name> date ---if we have more than one container we can
mention container name
# kubectl exec -it <pod name> /bin/bash --to enter into container
# kubectl logs -f<pod name> --to see logs from running container
Pod manifest file
Name and app = is our choise ,we can give any name
# Kubectl delete -f filename.yml -- it wii delete all the objects which are part of this manifest file
including pods and rc
# Kubectl delete rc rcname --- it wii delete all the objects which are part of this manifest file including
pods and rc
# Kubectl edit deploy deploymentname --- it is also to change version (after enter this command
deployment file will be open then just change version number then save and exit then it will get
automatically updated)
# Kubectl rollout status deployment/deployment name --- to check roll out successfully done or not
# kubectl set image deploy deployment name container name:version --record -- when we minction
record ,it will record all logs
# kubectl rollout undo deployment/deployment name --to roll back to older version
Job
Secrets
We can create secrets in two ways 1 .kubectl 2.manifest file
Syntax to creating secrets by using kubectl command
Manifest file for creating secrets
we can mount secrets into the pod in two ways
Using volume
Using environmental variable
PV and PVC
pdname = persistence disk name
fstype = file system type
We need to create persistent disk storage on google cloud before mention it in pv manifest
file (gcePerssistentdisk:)
(pdName: my-data-disk)
( filetype: ext4)
If we are not created it getting error like this
awsElasticBlockStore ----in aws
Dynamic pv
We can create multiple pvc s on same storageclass
Daemonset
What is the difference between kubectl create and kubectl apply
kubectl create can only be used if there are no existing resources and if you
want to create new resources.
If the resource is already created and running, create will raise an error, To avoid
that, use the kubectl get command to check if there is already an existing
resource; then use kubectl apply to update to the latest configuration.
HELM
What is helm chart ?
Helm chart is package manager for our Kubernetes cluster and it contains all the resource yaml files
of application , it responsible for upgrading , installation and uninstallation of software packages
# Tree helloworld
helloworld
├── charts
├── Chart.yaml
├── templates
│ ├── deployment.yaml
│ ├── _helpers.tpl
│ ├── hpa.yaml
│ ├── ingress.yaml
│ ├── NOTES.txt
│ ├── serviceaccount.yaml
│ ├── service.yaml
│ └── tests
│ └── test-connection.yaml
└── values.yaml
# helm template helm chart name it will show template which consist all resource of k8s
# helm lint helm chart name it will show all chat errors that we done in helm chart
# helm install <FIRST_RELEASE_NAME> <CHART_NAME>
Ex: #helm install myhelloworld helloworld to install helm chart
# Helm repo index helloworld to create index.yaml inside our packaged charts directory
# helm upgrade <release name> <helm chart name> to update helm chart
# helm rollback <release name> <revision number> we can rollback to any revision
Note: release name not contain upper characters(capital latters), space and special characters
# Helm install –set replicacount=2 <release name> <helm chart nmae> to increase replicacount
without opening value.yaml file
Namespace
Name space helps you to isolating group of k8s resources with in single cluster. names of resources
need to be unique within a single namespace ,but not across the namespace
# kubectl get pods -n <namespace name> to list all pods under the specific namespace
# Kubectl get all --all-namespaces it list all resources of namepaces
# kubectl get all -n namespacename it will list all resources of specific namepacs
# kubectl config set-context --current --namespace
What is ingress
Kubernetes ingress is not a service but a collection of routing rules that govern how the
external users access services running on the Kubernetes cluster. Ingress sits in front of
the cluster and acts as a smart router. This is always implemented using a third party
called a proxy. Traffic routing is done by an ingress controller.
Secrets
After creating screts we need to mount it into pod
Volume
Environmental variable
Config maps
Syntax of config map
We can create config map in 3 ways
1.dir
Creating config map using map
We can mount config map into pod in two ways 1 .volumes 2.environments
literal
environment