Day -3 Installation of k8s
Arjun Adhikari
DevOps | kubernetes | Linux | AWS | Terraform | Ansible |SQL | GIT | Docker | Shell Script | Networking
Minikube is an open-source tool that enables users to set up a Kubernetes cluster on their local machine. It's a great option for developers and system administrators who wish to experiment with Kubernetes without the inconvenience of creating a complete cluster..
Prerequisites
Before we begin, make sure that your Ubuntu 22.04 machine meets the following requirements:
Installation of minikube
$ sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
$ sudo echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
$sudo apt update
$sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
$sudo usermod -aG docker ubuntu
$ sudo apt update & sudo apt upgrade
$ sudo apt install -y curl wget apt-transport-https
Use the following curl command to download latest minikube binary
$ curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
Once the binary is downloaded, use the following command to install Minikube
$ sudo install minikube-linux-amd64 /usr/local/bin/minikube
Verifying Minikube installation
$ minikube version
minikube version: v1.32.0
commit: 8220a6eb95f0a4d75f7f2d7b14cef975f050512d
kubectl is a command line used to interact with Kubernetes cluster. It is used for managing deployments, replica sets, services, etc. Use the following command to download the latest version of kubectl.
$ curl -LO https://storage.googleapis.com/kubernetes-release/release/"curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt"/bin/linux/amd64/kubectl
Once kubectl is downloaded then set the executable permissions on kubectl binary and move it to the path /usr/local/bin.
领英推荐
$ chmod +x kubectl
$ sudo mv kubectl /usr/local/bin/
Now, verify the kubectl version
$ kubectl version -o yaml
clientVersion:
buildDate: "2023–11–15T16:58:22Z"
compiler: gc
gitCommit: bae2c62678db2b5053817bc97181fcc2e8388103
gitTreeState: clean
gitVersion: v1.28.4
goVersion: go1.20.11
major: "1"
minor: "28"
platform: linux/amd64
kustomizeVersion: v5.0.4–0.20230601165947–6ce0bf390ce3
serverVersion:
buildDate: "2023–10–18T11:33:18Z"
compiler: gc
gitCommit: a8a1abc25cad87333840cd7d54be2efaf31a3177
gitTreeState: clean
gitVersion: v1.28.3
goVersion: go1.20.10
major: "1"
minor: "28"
platform: linux/amd64
As we already stated in the beginning that we would be using docker as base for Minikube. To start the minikube with the docker driver, run the following command:
$ minikube start — driver=docker
In case Minikube cannot start because there is error regarding the Docker driver. Possible error:
$ minikube start --driver=docker
?? minikube v1.32.0 on Ubuntu 20.04 (amd64)
? Using the docker driver based on existing profile
?? The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.
?? If you are running minikube within a VM, consider using --driver=none:
?? https://minikube.sigs.k8s.io/docs/reference/drivers/none/
?? Tip: To remove this root owned cluster, run: sudo minikube delete
? Exiting due to DRV_AS_ROOT: The "docker" driver should not be used with root privileges.
Use the following command to force start:
$ minikube start --driver=docker --force
The output would be like below:
$ minikube start --driver=docker --force
?? minikube v1.32.0 on Ubuntu 20.04 (amd64)
? minikube skips various validations when --force is supplied; this may lead to unexpected behavior
? Using the docker driver based on existing profile
?? The "docker" driver should not be used with root privileges. If you wish to continue as root, use --force.
?? If you are running minikube within a VM, consider using --driver=none:
?? https://minikube.sigs.k8s.io/docs/reference/drivers/none/
?? Tip: To remove this root owned cluster, run: sudo minikube delete
?? Starting control plane node minikube in cluster minikube
?? Pulling base image ...
?? Restarting existing docker container for "minikube" ...
?? Preparing Kubernetes v1.28.3 on Docker 24.0.7 ...
?? Configuring bridge CNI (Container Networking Interface) ...
?? Verifying Kubernetes components...
?? Some dashboard features require the metrics-server addon. To enable all features please run:
minikube addons enable metrics-server
?? Enabled addons: storage-provisioner, default-storageclass
?? Done! kubectl is now configured to use "minikube" cluster and "default" namespace by default
Perfect, the above picture confirms that Minikube cluster has been confugured and started successfully.
Use the following command to verify Minikube:
$ minikube status
minikube
type: Control Plane
host: Running
kubelet: Running
apiserver: Running
kubeconfig: Configured
Use the following command to verify Kubernetes:
$ kubectl cluster-info
Kubernetes control plane is running at https://192.168.49.2:8443
CoreDNS is running at https://192.168.49.2:8443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy
To further debug and diagnose cluster problems, use 'kubectl cluster-info dump'.
Use the following command to test Kubernetes:
$ kubectl get nodes
NAME STATUS ROLES AGE VERSION
minikube Ready control-plane 25h v1.28.3
Technical Support Engineer
11 个月I'll keep this in mind
Graduated from Kathmandu University (KU)
11 个月Good going ??