X-Git-Url: https://gerrit.akraino.org/r/gitweb?a=blobdiff_plain;f=blueprints%2FuCPE%2Fk8smaster.sh;fp=blueprints%2FuCPE%2Fk8smaster.sh;h=924ee1d669767ef711463582e45f6de06f5961d9;hb=d63c1f66c2bbff6cd07ac5708f9939455b498b6a;hp=0000000000000000000000000000000000000000;hpb=a25e2c6b61cefe449f53a81e1a9f0b39a0a6208c;p=eliot.git diff --git a/blueprints/uCPE/k8smaster.sh b/blueprints/uCPE/k8smaster.sh new file mode 100644 index 0000000..924ee1d --- /dev/null +++ b/blueprints/uCPE/k8smaster.sh @@ -0,0 +1,60 @@ +#!/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/rbac.yaml" + kubectl apply -f "cni/calico/v38/calico.yaml" + +fi