Get info about the cluster :
kubectl cluster-info
Get the nodes :
kubectl get nodes
With labels :
kubectl get nodes --show-labels
Create a namespace :
kubectl create namespace devoxxfr
Set the context to this namespace :
kubectl config set-context --current --namespace=devoxxfr
Monitor the events :
watch kubectl get events --sort-by=.metadata.creationTimestamp
Create deployment :
kubectl create deployment devoxxfr23 --image sebi2706/devoxxfr23:1.0
Display pods :
kubectl get pods
with labels :
kubectl get pods --show-labels
Get into the pod :
kubectl exec -it pod-id -- /bin/bash
Inside the pod :
curl localhost:8080/hello
Describe pod :
kubectl describe pod pod-id
Delete a pod :
kubectl delete pod pod-id
Scale deployment :
kubectl scale deployment devoxxfr23 --replicas 3
kubectl expose deployment devoxxfr23 --port 8080 --type=LoadBalancer
Get service :
kubectl get service
If public IP is available : curl public_ip:8080/hello
kubectl set image deployment/devoxxfr23 devoxxfr23=sebi2706/devoxxfr23:2.0
Create new namespace :
kubectl create deployment devoxxfr-manifests
kubectl config set-context --current --namespace=devoxxfr-manifests
kubectl apply -f manifests/devoxxfr23-v1-deployment.yml
Edit deployment :
kubectl edit deployment/devoxxfr23
Look for replicas
, set it to 2
, save and exit.
kubectl apply -f manifests/devoxxfr23-service.yml
Setting just the cpu request (very high) and check pod going in pending
status :
kubectl apply -f manifests/devoxxfr23-v1-deployment-10cpus.yml
Setting requests and limits :
kubectl apply -f manifests/devoxxfr23-v1-deployment-limits.yml
kubectl apply -f manifests/devoxxfr23-v1-deployment-health.yml
Go into the pod :
kubectl exec -it pod-id -- /bin/bash
Force the readiness probe to fail :
curl localhost:8080/health/misbehave
Observe pod's status.
Make pod ready again :
curl localhost:8080/health/behave
Make pod a zombie and make liveness check fail :
curl localhost:8080/health/shoot
Observice pod getting restarted.
Deploy a second version of the deployment :
kubectl apply manifests/devoxxfr23-v2-deployment-health.yml
2 new pods should appear (replicas
is set to 2
for v2)
Edit service :
kubectl edit svc/devoxxfr23
Look for selector
section is set it to :
selector:
app.kubernetes.io/name: devoxxfr23-v2
app.kubernetes.io/version: "2.0"
Save and exit.
kubectl set env deployment/devoxxfr23-v2 GREETING=hola
kubectl create cm my-config --from-env-file=my.properties
kubectl apply -f manifests/devoxxfr23-v1-deployment-configmap
kubectl create secret generic mysecret --from-literal=user='MyUserName' --from-literal=password='mypassword'
kubectl get secret mysecret -o yaml
kubectl replace -f manifests/devoxxfr23-v1-deployment-secrets.yml
kubectl describe nodes | egrep "Name:|Taints:"
kubectl taint nodes --all=true color=blue:NoSchedule
kubectl taint node devnation-m02 color:NoSchedule-
kubectl taint nodes --all=true color=blue:NoSchedule --overwrite
kubectl label nodes devnation-m02 color=blue