Editing Kubectl

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 1: Line 1:
{{lowercase}}
+
<code>kubectl</code> is a command line interface for running commands against [[Kubernetes]] clusters.<ref>https://kubernetes.io/docs/reference/kubectl/overview/</ref>
<code>[[wikipedia:kubectl]]</code> is a command line interface for running commands against [[Kubernetes]] clusters.<ref>https://kubernetes.io/docs/reference/kubectl/overview/</ref>
 
  
== Installation ==
+
To install in MacOS execute: <code>brew install kubernetes-cli</code>
* To install in [[macOS]] execute: <code>[[brew install kubernetes-cli]]</code>
 
* [[Kubectl in Amazon Linux]]
 
* [[Ubuntu kubectl installation]]
 
* <code>[[~/.kube/config]]</code>
 
* [[scoop install kubectl]]
 
  
== Commands ==
+
== kubectl info commands ==
* <code>[[kubectl --help]]</code>
+
* Verify running [[Pod]]s:
* <code>[[kubectl api-versions]]</code>
+
** <code>[[kubectl get pods]]</code>
* <code>[[kubectl apply]]</code>
+
** <code>[[kubectl get]] pod PODNAME</code>
* <code>[[kubectl auth]]</code>
+
** <code>kubectl get pod PODNAME -n MY_NAMESPACE</code>
* <code>[[kubectl create]]</code>
+
** <code>kubectl get pod PODNAME -n MY_NAMESPACE --watch</code>
* <code>[[kubectl completion]]</code>
+
* Fetch metrics for PODNAME pod <code>kubectl top pod PODNAME</code>
* <code>[[kubectl config]]</code>: <code>[[kubectl config use-context|config-use-context]]</code>
 
* <code>[[kubectl cp]]</code>
 
* <code>[[kubectl debug]]</code> (since [[v1.18]], March 2020)
 
* <code>[[kubectl delete]]</code>
 
* <code>[[kubectl describe]]</code>
 
* <code>[[kubectl diff]]</code> (since [[v1.18]], March 2020)
 
* <code>[[kubectl edit]]</code>
 
* <code>[[kubectl explain]]</code>
 
* <code>[[kubectl expose]]</code>
 
* <code>[[kubectl exec]]</code>
 
* <code>[[kubectl get]] [[kubectl get all|all]] | [[kubectl get nodes|nodes]] | [[kubectl get pvc|pvc]] | [[kubectl get pods|pods]] | [[kubectl get replicaset|replicaset]] .../... </code>  
 
* <code>[[kubectl label]]</code>
 
* <code>[[kubectl logs]]</code>
 
* <code>[[kubectl patch]]</code>
 
* <code>[[kubectl port-forward]]</code>
 
* <code>[[kubectl proxy]]</code>
 
* <code>[[kubectl plugin]]</code>
 
* <code>[[kubectl replace]]</code>
 
* <code>[[kubectl rolling-update]]</code>
 
* <code>[[kubectl rollout]]</code>
 
* <code>[[kubectl set]]</code>
 
* <code>[[kubectl top]]</code>
 
* <code>[[kubectl virt]]</code>
 
 
 
== [[Kubectl information commands]] ==
 
{{kubectl information TOC}}
 
  
 
== kubectl operation commands ==
 
== kubectl operation commands ==
Line 59: Line 27:
  
  
*'''Cluster Info''' <code>[[kubectl cluster-info]] [flags]</code> :Display endpoint information about the master and services in the cluster
+
*'''Cluster Info''' <code>kubectl cluster-info [flags]</code> :Display endpoint information about the master and services in the cluster
  
*'''Create''' <code>[[kubectl create]] -f FILENAME [flags]</code>: Create one or more resources from a file or stdin
+
*'''Create''' <code>kubectl create -f FILENAME [flags]</code>: Create one or more resources from a file or stdin
 
** <code>kubectl create namespace myexamplenamespace</code>
 
** <code>kubectl create namespace myexamplenamespace</code>
 
** <code>kubectl create sa my_new_user</code> (Create service account for your my_new_user)
 
** <code>kubectl create sa my_new_user</code> (Create service account for your my_new_user)
Line 68: Line 36:
  
 
*'''Config''': <code>kubectl config .../...</code>
 
*'''Config''': <code>kubectl config .../...</code>
** <code>[[kubectl config view]]</code>
+
** <code>kubectl config view</code>
  
 
*'''Delete''' <code>kubectl delete (-f FILENAME \| TYPE [NAME \| /NAME \| -l label \| --all]) [flags]</code> :Delete resources  
 
*'''Delete''' <code>kubectl delete (-f FILENAME \| TYPE [NAME \| /NAME \| -l label \| --all]) [flags]</code> :Delete resources  
Line 86: Line 54:
  
 
* '''[[kubectl get|Get]]''':  
 
* '''[[kubectl get|Get]]''':  
 +
** <code>kubectl get apiservices</code>
 +
** <code>kubectl get nodes</code>
 +
** <code>kubectl get pods</code>
 +
** <code>kubectl get pod PODNAME -n NAMESPACE -o yaml | kubectl replace --force -f -</code><ref>https://stackoverflow.com/a/45046340/9269906</ref>
  
* '''Replace''': <code>[[kubectl replace]] --force -f yml_file_describing_pod.yml</code>
+
* '''Replace''': <code>kubectl replace --force -f yml_file_describing_pod.yml</code>
  
* '''Proxy''': <code>[[kubectl proxy]] --port=8080</code><ref>https://kubernetes.io/docs/tasks/access-kubernetes-api/http-proxy-access-api/</ref>
+
* '''Proxy''': <code>kubectl proxy --port=8080</code><ref>https://kubernetes.io/docs/tasks/access-kubernetes-api/http-proxy-access-api/</ref>
  
 
* '''Rolling-update:''' <code>[[kubectl rolling-update]]</code>
 
* '''Rolling-update:''' <code>[[kubectl rolling-update]]</code>
  
*'''Run''' <code>[[kubectl run]] NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [flags]</code>: Run a specified image on the cluster.
+
*'''Run''' <code>kubectl run NAME --image=image [--env="key=value"] [--port=port] [--replicas=replicas] [--dry-run=bool] [--overrides=inline-json] [flags]</code>: Run a specified image on the cluster.
  
*'''Scale''': <code>[[kubectl scale]] deployment YOUR_DEPLOYMENT_NAME</code>
+
*'''Scale''': <code>kubectl scale deployment YOUR_DEPLOYMENT_NAME</code>
  
 
*'''Stop''' <code>kubectl stop</code>
 
*'''Stop''' <code>kubectl stop</code>
Line 103: Line 75:
 
== Activities ==
 
== Activities ==
 
* [[Create and configure a basic Pod]] (<code>[[kubectl apply]]</code>)
 
* [[Create and configure a basic Pod]] (<code>[[kubectl apply]]</code>)
* Read official <code>kubectl</code> cheat sheet: https://kubernetes.io/docs/reference/kubectl/cheatsheet/
 
* Check examples: https://www.codegrepper.com/code-examples/shell/kubectl+describe+ingress+output+yaml
 
* https://stackoverflow.com/questions/tagged/kubectl?tab=Votes
 
* [[Kubernetes quiz]]
 
* [[Merge multiple kubeconfigs]]: <code>[[~/.kube/config]]s</code> into one using <code>[[kubectl konfig merge]]</code>
 
 
== Related ==
 
* [[Krew]]
 
* <code>[[kops]]</code>
 
* [[Kots]] kubectl plugin
 
* [[K9s]]
 
* <code>[[aws eks]] --region $([[terraform output -raw]] region) [[update-kubeconfig]] --name $([[terraform output -raw]] cluster_name)</code>
 
* <code>[[kubectl-convert]]</code>
 
* <code>[[kubeadm]]</code>
 
* <code>[[Error: flags cannot be place before plugin name]]</code>
 
* <code>[[kubectl.kubernetes.io]]</code>
 
* [[kubectl (alias)]]
 
* [[Terraform: kubectl provider]]
 
  
 
== See also ==
 
== See also ==
* {{Kubernetes components}}
 
 
* {{kubectl}}
 
* {{kubectl}}
 +
* {{k8s}}
 +
 +
[[Category: Software development]]
 +
[[Category:Server administration]]
  
[[Category: Kubernetes]]
 
[[Category: kubectl]]
 
  
 
{{CC license}}
 
{{CC license}}
 
Source: https://en.wikiversity.org/wiki/DevOps/Kubernetes/kubectl
 
Source: https://en.wikiversity.org/wiki/DevOps/Kubernetes/kubectl

Please note that all contributions to wikieduonline may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see Wikieduonline:Copyrights for details). Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Advertising: