Kubernetes

Table of Contents

1. Deploy a Pod

Deploy a simple pod with a specified image.

kubectl run mypod --image=nginx

2. List Pods

View the status of all pods running in the current namespace.

kubectl get pods

3. Pod Details

Retrieve comprehensive information about a specific pod.

kubectl describe pod pod_name

4. Scale a Deployment

Adjust the number of replicas for a deployment.

kubectl scale deployment myapp --replicas=3

5. Expose a Service

Expose a service to make it accessible from outside the cluster.

kubectl expose deployment myapp --port=80 --type=LoadBalancer

6. Update a Deployment

Roll out a new image for a deployment.

kubectl set image deployment/myapp myapp-container=myapp:v2

7. Pod Logs

Retrieve logs from a specific pod.

kubectl logs pod_name

8. Delete a Pod

Terminate and delete a specific pod.

kubectl delete pod pod_name

9. List Services

View details of all services running in the current namespace.

kubectl get services

10. Service Details

Retrieve comprehensive information about a specific service.

kubectl describe service service_name

11. Delete a Service

Delete a specific service.

kubectl delete service service_name

12. Config Maps

Create a config map to store configuration data.

kubectl create configmap config-map-name --from-file=path/to/config/files

13. Secrets

Create a secret to store sensitive information.

kubectl create secret generic secret-name --from-literal=key=value

14. Get Nodes

View information about all nodes in the Kubernetes cluster.

kubectl get nodes

15. Namespace Creation

Establish a new namespace for organizing resources.

kubectl create namespace my-namespace