{"id":1221,"date":"2021-01-08T11:04:34","date_gmt":"2021-01-08T11:04:34","guid":{"rendered":"https:\/\/blog.samarthya.me\/wps\/?p=1221"},"modified":"2021-01-08T11:06:52","modified_gmt":"2021-01-08T11:06:52","slug":"quick-cheat-sheet","status":"publish","type":"post","link":"https:\/\/blog.samarthya.me\/wps\/2021\/01\/08\/quick-cheat-sheet\/","title":{"rendered":"Quick: Cheat Sheet"},"content":{"rendered":"<p>A cheat sheet for Installing K8S cluster.<\/p>\n\n\n<h2 class=\"wp-block-heading\">Step1:<\/h2>\n\n\n\n<pre class=\"wp-block-code\"><code>Check your OS?<\/code><\/pre>\n\n\n\n<ul class=\"wp-block-list\"><li><code>cat \/etc\/issue<\/code><\/li><li><code>lsb_release -a<\/code><\/li><\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Step 2:<\/h2>\n\n\n\n<p>Add the GPG key as described <a href=\"https:\/\/docs.docker.com\/engine\/install\/ubuntu\/\">here<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -fsSL https:\/\/download.docker.com\/linux\/ubuntu\/gpg | sudo apt-key add -<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 3:<\/h2>\n\n\n\n<p>Add repository<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo add-apt-repository \\\n   \"deb &#91;arch=amd64] https:\/\/download.docker.com\/linux\/ubuntu \\\n   $(lsb_release -cs) \\\n   stable\"<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 4:<\/h2>\n\n\n\n<p>GPG for K8S as mentioned <a href=\"https:\/\/kubernetes.io\/docs\/setup\/production-environment\/tools\/kubeadm\/install-kubeadm\/\">here<\/a><\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>curl -s https:\/\/packages.cloud.google.com\/apt\/doc\/apt-key.gpg | sudo apt-key add -<\/code><\/pre>\n\n\n\n<p>add the repostiory too<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat &lt;&lt;EOF | sudo tee \/etc\/apt\/sources.list.d\/kubernetes.list\ndeb https:\/\/apt.kubernetes.io\/ kubernetes-xenial main\nEOF<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 5:<\/h2>\n\n\n\n<p>Run apt update<\/p>\n\n\n\n<p><code>sudo apt-get update<\/code><\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Step 6:<\/h2>\n\n\n\n<p>Installing latest can be accomplished by using<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt-get install -y kubelet kubeadm kubectl\nsudo apt-mark hold kubelet kubeadm kubectl<\/code><\/pre>\n\n\n\n<p>I did a specific version<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo apt install -y docker-ce=5:19.03.10~3-0~ubuntu-focal kubelet=1.18.5-00 kubeadm=1.18.5-00 kubectl=1.18.5-00<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 7:<\/h2>\n\n\n\n<p>Depending on which third-party provider you choose, you might need to set the <code>--pod-network-cidr<\/code> to a provider-specific value. See <a href=\"https:\/\/kubernetes.io\/docs\/setup\/production-environment\/tools\/kubeadm\/create-cluster-kubeadm\/#pod-network\">Installing a Pod network add-on<\/a>.<\/p>\n\n\n\n<figure class=\"wp-block-pullquote is-style-solid-color\"><blockquote><p>Choose a Pod network add-on, and verify whether it requires any arguments to be passed to <code>kubeadm init<\/code>. <\/p><\/blockquote><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo kubeadm init --pod-network-cidr=10.244.0.0\/16<\/code><\/pre>\n\n\n\n<p>It might give an output at the end like this<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;addons] Applied essential addon: CoreDNS\n&#91;addons] Applied essential addon: kube-proxy\n\nYour Kubernetes control-plane has initialized successfully!\n\nTo start using your cluster, you need to run the following as a regular user:\n\n  mkdir -p $HOME\/.kube\n  sudo cp -i \/etc\/kubernetes\/admin.conf $HOME\/.kube\/config\n  sudo chown $(id -u):$(id -g) $HOME\/.kube\/config\n\nYou should now deploy a pod network to the cluster.\nRun \"kubectl apply -f &#91;podnetwork].yaml\" with one of the options listed at:\n  https:&#47;&#47;kubernetes.io\/docs\/concepts\/cluster-administration\/addons\/\n\nThen you can join any number of worker nodes by running the following on each as root:\n\nkubeadm join 10.0.1.101:6443 --token 0s94g0.l7q69nvf7jwa2vxm \\\n    --discovery-token-ca-cert-hash sha256:559f153599b382e2a4551b15360e111cca40bde56889448eedce0c6ae733b0e4 <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 8:<\/h2>\n\n\n\n<p>Follow the steps before you can use cluster as mentioned in output and keep not of the join command<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>mkdir -p $HOME\/.kube\nsudo cp -i \/etc\/kubernetes\/admin.conf $HOME\/.kube\/config\nsudo chown $(id -u):$(id -g) $HOME\/.kube\/config<\/code><\/pre>\n\n\n\n<p>Do not issue the join command on the master node, as it is meant for nodes.<\/p>\n\n\n\n<p>Follow <code>Step 1 - 6<\/code> on the machines that you want to be part of the cluster<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kubeadm join 10.0.1.101:6443 --token 0s94g0.l7q69nvf7jwa2vxm \\\n    --discovery-token-ca-cert-hash sha256:559f153599b382e2a4551b15360e111cca40bde56889448eedce0c6ae733b0e4 <\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 9:<\/h2>\n\n\n\n<p>Install network-add on.<\/p>\n\n\n\n<figure class=\"wp-block-pullquote has-background has-luminous-vivid-orange-background-color is-style-solid-color\"><blockquote class=\"has-text-color has-white-color\"><p><strong>Note:<\/strong> Currently Calico is the only CNI plugin that the kubeadm project performs e2e tests against. If you find an issue related to a CNI plugin you should log a ticket in its respective issue tracker instead of the kubeadm or kubernetes issue trackers.<\/p><\/blockquote><\/figure>\n\n\n\n<pre class=\"wp-block-code\"><code> kubectl apply -f https:\/\/docs.projectcalico.org\/v3.14\/manifests\/calico.yaml<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Step 10:<\/h2>\n\n\n\n<p>On node machines use the join command to join the cluster. It would show an output at the end like below<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;kubelet-start] Downloading configuration for the kubelet from the \"kubelet-config-1.18\" ConfigMap in the kube-system namespace\n&#91;kubelet-start] Writing kubelet configuration to file \"\/var\/lib\/kubelet\/config.yaml\"\n&#91;kubelet-start] Writing kubelet environment file with flags to file \"\/var\/lib\/kubelet\/kubeadm-flags.env\"\n&#91;kubelet-start] Starting the kubelet\n&#91;kubelet-start] Waiting for the kubelet to perform the TLS Bootstrap...\n\nThis node has joined the cluster:\n* Certificate signing request was sent to apiserver and a response was received.\n* The Kubelet was informed of the new secure connection details.\n\nRun 'kubectl get nodes' on the control-plane to see this node join the cluster.<\/code><\/pre>\n\n\n\n<h2 class=\"wp-block-heading\">Conclusion<\/h2>\n\n\n\n<p>Check for the nodes joining the cluster using<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl get nodes\nNAME            STATUS   ROLES    AGE   VERSION\nip-10-0-1-101   Ready    master   28m   v1.18.5\nip-10-0-1-102   Ready    &lt;none&gt;   26m   v1.18.5\nip-10-0-1-103   Ready    &lt;none&gt;   26m   v1.18.5<\/code><\/pre>\n\n\n\n<p>You can also follow it up by creating a quick deployment using the NGINX image as below<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl create deployment nginx --image=nginx<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl get deploy\nNAME    READY   UP-TO-DATE   AVAILABLE   AGE\nnginx   1\/1     1            1           29m<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl get pods\nNAME                    READY   STATUS    RESTARTS   AGE\nnginx-f89759699-hqvcm   1\/1     Running   0          30m<\/code><\/pre>\n\n\n\n<p>Try exposing the port<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>kubectl expose --help<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>A cheat sheet for Installing K8S cluster. Step1: cat \/etc\/issue lsb_release -a Step 2: Add the GPG key as described here Step 3: Add repository Step 4: GPG for K8S as mentioned here add the repostiory too Step 5: Run apt update sudo apt-get update Step 6: Installing latest can be accomplished by using I [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":1225,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"image","meta":{"_exactmetrics_skip_tracking":false,"_exactmetrics_sitenote_active":false,"_exactmetrics_sitenote_note":"","_exactmetrics_sitenote_category":0,"footnotes":""},"categories":[86,34],"tags":[45,82,18,135,84],"class_list":["post-1221","post","type-post","status-publish","format-image","has-post-thumbnail","hentry","category-docker","category-technical","tag-cluster","tag-docker","tag-k8s","tag-kubeadm","tag-ubuntu","post_format-post-format-image"],"_links":{"self":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/1221","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/comments?post=1221"}],"version-history":[{"count":0,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/posts\/1221\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media\/1225"}],"wp:attachment":[{"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/media?parent=1221"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/categories?post=1221"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.samarthya.me\/wps\/wp-json\/wp\/v2\/tags?post=1221"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}