Kubectl is Kubernetes command line interface
- Kubectl uses the Kubernetes API to interact with the cluster
- The common format of a kubectl command is:
kubectl action resource This performs the specified action (like create, describe or delete) on the specified resource (like node or deployment). You can use
--helpafter the subcommand to get additional info about possible parameters (for example:kubectl get nodes --help).Check that kubectl is configured to talk to your cluster, by running the
kubectl versioncommand.Check that kubectl is installed and you can see both the client and the server versions.
To view the nodes in the cluster, run the
kubectl get nodescommand.The most common operations can be done with the following kubectl subcommands:
- kubectl get - list resources
- kubectl describe - show detailed information about a resource
- kubectl logs - print the logs from a container in a pod
- kubectl exec - execute a command on a container in a pod
You can use these commands to see when applications were deployed, what their current statuses are, where they are running and what their configurations are
Deploy an app using kubectl
Let’s deploy our first app on Kubernetes with the
kubectl create deploymentcommand. We need to provide the deployment name and app image location (include the full repository url for images hosted outside Docker Hub).kubectl create deployment kubernetes-bootcamp --image=gcr.io/google-samples/kubernetes-bootcamp:v1Great! You just deployed your first application by creating a deployment. This performed a few things for you:
- searched for a suitable node where an instance of the application could be run (we have only 1 available node)
- scheduled the application to run on that Node
- configured the cluster to reschedule the instance on a new Node when needed
To list your deployments use the
kubectl get deploymentscommand
Comments
Post a Comment