Skip to content

Instantly share code, notes, and snippets.

@rgodishela
Created June 26, 2018 16:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rgodishela/2e9de309341f86918a52770949bdacea to your computer and use it in GitHub Desktop.
Save rgodishela/2e9de309341f86918a52770949bdacea to your computer and use it in GitHub Desktop.
Liveness check
#Install Google cloud SDK
curl https://sdk.cloud.google.com | bash
exec -l $SHELL
# Setup the GCP to work with gcloud, enable required API's
gcloud init
gcloud config set project PROJECT_ID
gcloud config set compute/zone COMPUTE_ZONE
#Create the cluster
gcloud container clusters create CLUSTER_NAME
#Get the kubeconfig file
gcloud container clusters get-credentials CLUSTER_NAME
#Check the k8s cluster health
kubectl cluster-info
#Create sample pod to see whether pods are being created or not
kubectl run hello-server --image gcr.io/google-samples/hello-app:1.0 --port 8080
#Expose the port
kubectl expose deployment hello-server --type LoadBalancer \
  --port 80 --target-port 8080
#Get the service and external IP
kubectl get service hello-server
#Access it from external network
http://EXTERNAL_IP/
#Delete the service
kubectl delete service hello-server
#Create the pod which will tell u about liveness ready
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/exec-liveness.yaml
#see whether the pod is created or not:
kubectl get pod liveness-exec
#Within 30 seconds, view the Pod events:
kubectl describe pod liveness-exec
#After 35 seconds, view the Pod events again & compare with the above outputs and observe.
kubectl describe pod liveness-exec
#Wait another 30 seconds, and verify that the Container has been restarted:
kubectl get pod liveness-exec
if you understand then u will be able to understand http and tcp liveness probe also
#To try the TCP liveness check, create a Pod:
kubectl create -f https://k8s.io/docs/tasks/configure-pod-container/tcp-liveness-readiness.yaml
#After 15 seconds, view Pod events to verify that liveness probes:
kubectl describe pod goproxy
#Delete the cluster
gcloud container clusters delete CLUSTER_NAME
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment