kubectl
Kubernetes, also known as K8s, is an open-source system for automating deployment, scaling and managing of containerized apps.
Now that we have an understanding what K8s let’s deploy our own cluster!
kind is a tool for running local Kubernetes clusters using Docker container “nodes.” kind was primarily designed for testing Kubernetes itself, but it may be used for local development or CI.
kind
to config and build our cluster.kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraPortMappings:
- containerPort: 30201
hostPort: 30201
listenAddress: "0.0.0.0"
kind: Cluster
: This config merely specifies that we are configuring a kind cluster.role: control-plane
: This config defines the Kubernetes control plane. The control plane’s components make global decisions about the cluster (for example, scheduling) as well as detecting and responding to cluster events.extraPortMappings
: This config specifies the port mapping for our container so that we can reach our cluster.kind-config.yaml
using cd <directory>
in your Terminalkind create cluster --name my-kubernetes-cluster --config kind-config.yaml
my-kubernetes-cluster
cluster was created, using your terminal execute:kind get clusters
kubectl
so we can interact with it, in your terminal execute:kubectl cluster-info --context kind-my-kubernetes-cluster
kubectl
, in your terminal execute:kubectl config view --minify --flatten --context=kind-my-kubernetes-cluster
You’ve made it this far! now that we have a Kubernetes cluster! we need a way to interact with it the standard command line employed to communicate with it is Kubectl
In your terminal, let’s try some commonly used kubectl
commands!
kubectl cluster-info
kubectl version
kubectl config view
kubectl api-resources
kubectl get all
In Kubernetes, namespaces provide a mechanism for isolating groups of resources within a single cluster.
kubectl create namespace my-first-ns
kubectl get namespaces
kubectl describe namespace my-first-ns
kubectl delete namespace my-first-ns
ℹ️ For a complete list of kubectl
commands and to learn more, check out this Cheat Sheet.
Congratulations! You’ve successfully completed this lab!