The Kubernetes kubectl
client is used to access the Kubernetes cluster. The following describes
how to install the client:
https://kubernetes.io/docs/tasks/tools/install-kubectl/
The kubectl
client uses the kubeconfig file to determine how to communicate with the Kubernetes
API server in various clusters. By default it will look for a $HOME/.kube/config
file. Take a
backup of any existing config file, and save the provided config file to that location.
kubectl cluster-info
An instance configured to monitor this cluster can be accessed here: https://dpfog.westus.cloudapp.azure.com:8443/
Start a proxy to the Kubernetes cluster:
kubectl proxy
Access the Kubernetes Dashboard: http://localhost:8001/api/v1/namespaces/kube-system/services/kubernetes-dashboard/proxy
Start a second proxy to forward local traffic to the Grafana service:
kubectl port-forward svc/grafana 3000:80
Access Grafana via the proxy: http://localhost:3000
- Edit the
yaml/hello-kubernetes.yaml
file - Search and replace in the file to change all instances of “foo” to your username (e.g. “jsmith”)
- Deploy the service with
kubectl apply -f yaml/hello-kubernetes.yaml
- Navigate to service specific endpoint http://13.88.137.222/jsmith
- Edit the
yaml/hello-kubernetes.yaml
file - Change the value of the
MESSAGE
environment variable - Deploy the updated configuration with
kubectl apply -f yaml/hello-kubernetes.yaml
- Use kubectl to ssh into a pod:
kubectl exec -it svc/hello-jsmith sh
- List the processing running:
ps -ef
- Kill the node server (PID 17?):
kill -9 17
- Will be disconnected since the pod ends when the container exits
- Should still be able to access the service specific endpoint http://13.88.137.222/jsmith
- Edit the
yaml/hello-kubernetes.yaml
file and modify the request and limit for memory to 1MiB:
resources:
requests:
memory: 1Mi
cpu: 0.05
limits:
memory: 1Mi
- Deploy the updated configuration:
kubectl apply -f yaml/hello-kubernetes.yaml
- Pod enters crash loop
- Service is still accessible because of rolling deploy leaves original version of pod running
- Edit the
yaml/hello-kubernetes.yaml
file and modify the request and limit for memory to 1MiB:
resources:
requests:
memory: 100Gi
cpu: 0.05
limits:
memory: 100Gi
- Deploy the updated configuration:
kubectl apply -f yaml/hello-kubernetes.yaml
- Kubernetes is not able to schedule the pod to run on any node in the cluster
- Service is still accessible
- Edit the
yaml/hello-kubernetes.yaml
file and restore the request and limit for memory to:
resources:
requests:
memory: 32Mi
cpu: 0.05
limits:
memory: 64Mi
- Deploy the updated configuration:
kubectl apply -f yaml/hello-kubernetes.yaml
- Kubernetes is able to complete the deployment