X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=blueprints%2Fiotgateway%2Fscripts%2Fkubeedge%2Fk8smaster.sh;fp=blueprints%2Fiotgateway%2Fscripts%2Fkubeedge%2Fk8smaster.sh;h=3723495041cd46b45a11c8d99c6a45f478f85cdc;hb=b7b9a88e07c4fb4c8b00582c90b3646f4a4ad0d4;hp=0000000000000000000000000000000000000000;hpb=d8231861fea9dbdb16952bc1a744a2f8046e1bcf;p=eliot.git diff --git a/blueprints/iotgateway/scripts/kubeedge/k8smaster.sh b/blueprints/iotgateway/scripts/kubeedge/k8smaster.sh new file mode 100755 index 0000000..3723495 --- /dev/null +++ b/blueprints/iotgateway/scripts/kubeedge/k8smaster.sh @@ -0,0 +1,59 @@ +#!/bin/bash -ex +############################################################################## +# Copyright (c) 2019 Huawei Tech and others. +# +# All rights reserved. This program and the accompanying materials +# are made available under the terms of the Apache License, Version 2.0 +# which accompanies this distribution, and is available at +# http://www.apache.org/licenses/LICENSE-2.0 +############################################################################## + +KUBE_VERSION=1.16.0-00 +POD_NETWORK_CIDR=192.168.0.0/16 +K8S_CNI_VERSION=0.7.5-00 + +#K8s service CIDR range +K8s_SVC_CIDR=10.96.0.0/12 + +# Install Kubernetes with Kubeadm + +# Disable swap +sudo swapoff -a +sudo apt update +sudo apt install -y apt-transport-https curl +curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - + +cat < hostname.tmp + MASTER_IP="$(cut -d ' ' -f 1 hostname.tmp)" + rm hostname.tmp + sudo kubeadm config images pull + sudo kubeadm init \ + --apiserver-advertise-address="${MASTER_IP}" \ + --pod-network-cidr="${POD_NETWORK_CIDR}" \ + --service-cidr="${K8s_SVC_CIDR}" + + if [ "$(id -u)" = 0 ]; then + KUBECONFIG=/etc/kubernetes/admin.conf + echo "export KUBECONFIG=/etc/kubernetes/admin.conf" | \ + tee -a "${HOME}/.profile" + source "${HOME}/.profile" + else + mkdir -p "${HOME}/.kube" + sudo cp -i /etc/kubernetes/admin.conf "${HOME}/.kube/config" + sudo chown "$(id -u)":"$(id -g)" "${HOME}/.kube/config" + fi + #kubectl apply -f "cni/calico/v38/calico.yaml" + +fi