Skip to content

Latest commit

 

History

History
113 lines (82 loc) · 2.98 KB

03_core_concepts.md

File metadata and controls

113 lines (82 loc) · 2.98 KB

1. Understand the Kubernetes API primitives

API overview is here.

All the Kubernetes API reference is here.

All the kubectl commands reference is here.

Create a static pod named static-busybox that uses the busybox image and the command sleep 1000

kubectl run --restart=Never --image=busybox static-busybox --dry-run -o yaml --command -- sleep 1000 > /etc/kubernetes/manifests/static-busybox.yaml

Use JSON PATH query to retrieve the osImages of all the nodes and store it in a file /opt/outputs/nodes_os_x43kj56.txt

kubectl get nodes -o jsonpath='{.items[*].status.nodeInfo.osImage}' > /opt/outputs/nodes_os_x43kj56.txt

Create an NGINX Pod

show

kubectl run nginx --generator=run-pod/v1 --image=nginx

Generate POD Manifest YAML file (-o yaml). Don't create it(--dry-run)

show

kubectl run nginx --generator=run-pod/v1 --image=nginx --dry-run -o yaml > nginx.yaml

Generate Deployment YAML file (-o yaml). Don't create it(--dry-run) with 4 Replicas (--replicas=4)

show

kubectl create deployment nginx --image=nginx --dry-run -o yaml > nginx-deployment.yaml

Open the nginx-deployment.yaml file that is created and modify replicas: 4

Create a Service named nginx of type NodePort to expose deployment nginx's port 80 on port 30080 on the nodes:

solusion 1

kubectl expose deploy nginx --type=NodePort --port=80 --dry-run -o yaml > nginx-service.yaml

Open and modify the file nginx-service.yaml, to add nodePort: 30080

solusion 2

Expose deployment nginx, this way the nodePort is randomly choosen between 30000-32767 , then use kubectl edit to modify the port of the service to nodePort: 30080

kubectl expose deploy nginx --type=NodePort --port=80 
kubectl edit svc nginx

Create a pod redis with image redis:alpine and label tier=db

show

kubectl run redis --generator=run-pod/v1 --image=redis:alpine -l tier=db

Create a Service named redis-service of type ClusterIP to expose pod redis on port 6379 with the label tier=db

show

kubectl expose pod redis --name redis-service --port=6379 -l tier=db

How a pod in a name space reach the service in another namespace (for example: dev namespace)

show

using something like:

db-service.dev.src.cluster.local

2.Understand the Kubernetes cluster architecture

3.Understand Services and other network primitives