Kubernetes has a large number of commands, and the specific commands you will use will depend on your use case. Here are some common Kubernetes commands and examples of their usage:

·         kubectl get: used to list resources in the cluster. For example, kubectl get pods will list all pods in the cluster.

·         kubectl describe: used to show detailed information about a specific resource. For example, kubectl describe pod my-pod will show detailed information about the pod named "my-pod".

·         kubectl create: used to create new resources. For example, kubectl create -f my-pod.yaml will create a new pod based on the configuration in the file "my-pod.yaml".

·         kubectl delete: used to delete resources. For example, kubectl delete pod my-pod will delete the pod named "my-pod".

·         kubectl apply: used to create or update resources. For example, kubectl apply -f my-deployment.yaml will create or update a deployment based on the configuration in the file "my-deployment.yaml".

·         ·  kubectl exec: used to execute a command in a running container. For example, kubectl exec -it my-pod -- bash will open a bash shell in the container of the pod named "my-pod"

·         ·  kubectl logs: used to view the logs of a specific pod. For example, kubectl logs my-pod will display the logs of the pod named "my-pod"

·         ·  kubectl scale: used to scale the replicas of a deployment. For example, kubectl scale deployment my-deployment --replicas=5 will scale the deployment named "my-deployment" to 5 replicas.

·         ·  kubectl port-forward: used to forward a local port to a port in a pod. For example, kubectl port-forward my-pod 8080:80 will forward local port 8080 to port 80 in the pod named "my-pod".

·         ·  kubectl cp: used to copy files to and from containers. For example, kubectl cp my-pod:/etc/config.txt . will copy the file "/etc/config.txt" from the pod named "my-pod" to the current directory on the local machine.

·         ·  kubectl top: used to show the resource usage of pods or nodes. For example, kubectl top pod will show the resource usage of all pods in the cluster.

·         ·  kubectl explain: used to show the documentation for a specific resource or field. For example, kubectl explain pod.spec will show the documentation for the "spec" field of a pod resource.

·         ·  kubectl run: used to create and run a new deployment. For example, kubectl run my-nginx --image=nginx will create a new deployment named "my-nginx" using the "nginx" image.

·         ·  kubectl expose: used to create a new service for a deployment. For example, kubectl expose deployment my-nginx --port=80 will create a new service for the deployment named "my-nginx" on port 80.

·         ·  kubectl attach: used to attach to a running container. For example, kubectl attach my-pod -c my-container will attach to the running container named "my-container" in the pod named "my-pod".

·         ·  kubectl rollout: used to view and manage the rollout of a deployment. For example, kubectl rollout status deployment my-deployment will show the status of the rollout for the deployment named "my-deployment".

·          

 

أحدث أقدم