Installation script for Kubernetes. 89/9689/1
authorsmahana123 <s.mahana@samsung.com>
Thu, 17 Nov 2022 10:05:19 +0000 (15:35 +0530)
committersmahana123 <s.mahana@samsung.com>
Thu, 17 Nov 2022 10:05:19 +0000 (15:35 +0530)
Issue-Id: AIMLFW-4

Signed-off-by: smahana123 <s.mahana@samsung.com>
Change-Id: I5910f1abdfa430b1c339ffb8fc369e4471264741

tools/kubernetes/install_k8s.sh [new file with mode: 0755]
tools/kubernetes/uninstall_k8s.sh [new file with mode: 0755]

diff --git a/tools/kubernetes/install_k8s.sh b/tools/kubernetes/install_k8s.sh
new file mode 100755 (executable)
index 0000000..2f0dbc3
--- /dev/null
@@ -0,0 +1,53 @@
+# ==================================================================================
+#
+#       Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#          http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+# ==================================================================================
+
+sudo apt-get install -y apt-transport-https
+sudo apt-get install -y apt-transport-https ca-certificates   curl gnupg lsb-release
+curl -fsSL https://download.docker.com/linux/ubuntu/gpg   | sudo gpg --dearmor   -o /usr/share/keyrings/docker-archive-keyring.gpg
+echo   "deb [arch=amd64 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
+sudo apt-get update -y
+sudo apt-get install -y docker-ce docker-ce-cli containerd.io
+sudo mkdir -p /etc/docker
+sudo cat > /tmp/daemon.json <<EOF
+{
+  "exec-opts": ["native.cgroupdriver=systemd"],
+  "log-driver": "json-file",
+  "log-opts": {
+    "max-size": "100m"
+  },
+  "storage-driver": "overlay2"
+}
+EOF
+
+sudo cp /tmp/daemon.json /etc/docker/daemon.json
+sudo systemctl restart docker
+sudo systemctl enable docker
+sudo curl -fsSLo /usr/share/keyrings/kubernetes-archive-keyring.gpg   https://packages.cloud.google.com/apt/doc/apt-key.gpg
+echo "deb [signed-by=/usr/share/keyrings/kubernetes-archive-keyring.gpg] https://apt.kubernetes.io/ kubernetes-xenial main"   | sudo tee /etc/apt/sources.list.d/kubernetes.list
+sudo apt-get update
+sudo apt-get install -y kubelet=1.21.0-00 kubectl=1.21.0-00 kubeadm=1.21.0-00
+sudo apt-mark hold kubelet kubeadm kubectl
+sudo swapoff -a
+sudo kubeadm init
+mkdir -p $HOME/.kube
+sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
+sudo chown $(id -u):$(id -g) $HOME/.kube/config
+curl https://projectcalico.docs.tigera.io/archive/v3.22/manifests/calico.yaml -O
+kubectl apply -f calico.yaml
+kubectl taint nodes --all node-role.kubernetes.io/master-
+
diff --git a/tools/kubernetes/uninstall_k8s.sh b/tools/kubernetes/uninstall_k8s.sh
new file mode 100755 (executable)
index 0000000..022de1b
--- /dev/null
@@ -0,0 +1,22 @@
+# ==================================================================================
+#
+#       Copyright (c) 2022 Samsung Electronics Co., Ltd. All Rights Reserved.
+#
+#   Licensed under the Apache License, Version 2.0 (the "License");
+#   you may not use this file except in compliance with the License.
+#   You may obtain a copy of the License at
+#
+#          http://www.apache.org/licenses/LICENSE-2.0
+#
+#   Unless required by applicable law or agreed to in writing, software
+#   distributed under the License is distributed on an "AS IS" BASIS,
+#   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+#   See the License for the specific language governing permissions and
+#   limitations under the License.
+#
+# ==================================================================================
+
+sudo kubeadm reset
+sudo apt-get -y purge kubeadm kubectl kubelet kubernetes-cni kube*
+sudo apt-get -y autoremove
+sudo rm -rf ~/.kube