# Interacting with Deployments and Services Kubectl top pod POD_NAME -sort-by=cpu # Show metrics for a given pod and sort it by 'cpu' or 'memory' Kubectl top pod POD_NAME -containers # Show metrics for a given pod and its containers Kubectl exec my-pod -c my-container - ls / # Run command in existing pod (multi-container case) Kubectl exec -stdin -tty my-pod - /bin/sh # Interactive shell access to a running pod (1 container case) Kubectl exec my-pod - ls / # Run command in existing pod (1 container case) Kubectl port-forward my-pod 5000:6000 # Listen on port 5000 on the local machine and forward to port 6000 on my-pod Kubectl attach my-pod -i # Attach to Running Container # Create multiple YAML objects from stdin Kubectl explain pods # get the documentation for pod manifests Kubectl create cronjob hello -image=busybox -schedule="*/1 * * * *" - echo "Hello World" # create a CronJob that prints "Hello World" every minute Kubectl create job hello -image=busybox - echo "Hello World" # create a Job which prints "Hello World" Kubectl create deployment nginx -image=nginx # start a single instance of nginx Kubectl apply -f # create resource(s) from url dir # create resource(s) in all manifest files in dir Kubernetes manifests can be defined in YAML or JSON. Is the recommended way of managing Kubernetes applications on production. ItĬreates and updates resources in a cluster through running `kubectl apply`. `apply` manages applications through files defining Kubernetes resources. Kubectl config unset users.foo # delete user foo Kubectl config set-context gce -user=cluster-admin -namespace=foo \ # set a context utilizing a specific username and namespace. Kubectl config set-context -current -namespace=ggckad-s2 # permanently save the namespace for all subsequent kubectl commands in that context. Kubectl config set-credentials kubeuser/ -username=kubeuser -password=kubepassword # add a new user to your kubeconf that supports basic auth Kubectl config use-context my-cluster-name # set the default context to my-cluster-name Kubectl config current-context # display the current-context Kubectl config get-contexts # display list of contexts Kubectl config view -o jsonpath='' # get a list of users Kubectl config view -o = "e2e")].user.password}' KUBECONFIG=~/.kube/config:~/.kube/kubconfig2 # use multiple kubeconfig files at the same time and view merged config Kubectl config view # Show Merged kubeconfig settings. See ()ĭocumentation for detailed config file information. Set which Kubernetes cluster `kubectl` communicates with and modifies configuration Source > ~/.zshrc # add autocomplete permanently to your zsh shell You can also use a shorthand alias for `kubectl` that also works with completion: Source > ~/.bashrc # add autocomplete permanently to your bash shell. > This page contains a list of commonly used `kubectl` commands and flags. Kubectl get pods -sort-by=.: This page contains a list of commonly used kubectl commands and flags. Kubectl get services -sort-by=.metadata.name Kubectl describe pods # Lists pods created by using common prefix Kubectl get pods -l env=production # List all pods with a label env=production Kubectl get rc # List a particular replication controller Kubectl get pods -o wide # List all pods in the namespace, with more details Kubectl get pods -all-namespaces # List all pods in all namespaces Kubectl get services # List all services in the namespace
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |