Skip to main content

Kubectl Quick Start

✍ Last Updated : September 19, 2022

🚪 Prequisite Knowledge (Optional)

[Kubernetes Basics](Kubernetes Basics 13d23a5871e14e34b61adac97169813b.md)

❓ Key Question / Problem / Issue

  1. how to check kubectl availability in your machine
  2. how to install kubectl
  3. How to start using kubectl
  4. simple usage on how to use kubectl

✅ Expected Output/Definition of Done

  1. Clear Guideline on how to start using kubectl in your machine and cluster

🎁 Resulting Solution

Overview

The Kubernetes command-line tool, kubectl, allows you to run commands against Kubernetes clusters. You can use kubectl to deploy applications, inspect and manage cluster resources, and view logs. For more information including a complete list of kubectl operations, see the reference documentation

Check Kubectl Installed

run

kubectl version

result

Client Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.5", GitCommit:"aea7bbadd2fc0cd689de94a54e5b7b758869d691", GitTreeState:"clean", BuildDate:"2021-09-15T21:10:45Z", GoVersion:"go1.16.8", Compiler:"gc", Platform:"windows/amd64"}        
Server Version: version.Info{Major:"1", Minor:"22", GitVersion:"v1.22.12", GitCommit:"b058e1760c79f46a834ba59bd7a3486ecf28237d", GitTreeState:"clean", BuildDate:"2022-07-13T14:53:39Z", GoVersion:"go1.16.15", Compiler:"gc", Platform:"linux/amd64"}

Install Kubectl

If your local computer doesn’t already have kubectl, follow this tutorial to install https://kubernetes.io/docs/tasks/tools/install-kubectl-windows/

Change Context

If you already installed kubectl on your local computer before, then it is recommended to check which cluster it’s currently using

The context should be agones

run

kubectl config current-context

result

agones

If your current context is not agones, you can directly set it to agones or you can check all available contexts using the commands below

Get All Contexts

run

kubectl config get-contexts

result

CURRENT    NAME    CLUSTER    AUTHINFO    NAMESPACE
*          agones  agones     agones      default

Set Context

run

kubectl config use-context agones

result

Switched to context "agones".

Get all pods in all namespaces to confirm if minikube is running

run

kubectl get pod -A

result

NAMESPACE     NAME                             READY   STATUS    RESTARTS        AGE
kube-system   coredns-78fcd69978-vk45b         1/1     Running   0               5m53s
kube-system   etcd-agones                      1/1     Running   0               6m6s
kube-system   kube-apiserver-agones            1/1     Running   0               6m6s
kube-system   kube-controller-manager-agones   1/1     Running   0               6m6s
kube-system   kube-proxy-whrxk                 1/1     Running   0               5m53s
kube-system   kube-scheduler-agones            1/1     Running   0               6m6s
kube-system   storage-provisioner              1/1     Running   1 (5m32s ago)   6m4s

at this point your cluster is ready, next, we will install Agones using Helm