This commit is contained in:
2019-10-02 18:27:25 +02:00
parent d6dd233e83
commit 14cb4ae908
45 changed files with 1333 additions and 0 deletions

5
deploy/calico_setup.sh Normal file
View File

@ -0,0 +1,5 @@
#!/bin/bash
## Apply Calico CNI plugin
kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/rbac-kdd.yaml
kubectl apply -f https://docs.projectcalico.org/v3.3/getting-started/kubernetes/installation/hosted/kubernetes-datastore/calico-networking/1.7/calico.yaml

4
deploy/cilium_setup.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
## Apply Cilium CNI plugin
kubectl create -f https://raw.githubusercontent.com/cilium/cilium/v1.4/examples/kubernetes/1.13/cilium.yaml

View File

@ -0,0 +1,7 @@
#!/bin/bash
IP=$1
sed "/ExecStart/ s/$/ --insecure-registry=$IP/" /lib/systemd/system/docker.service > /lib/systemd/system/tmp
mv /lib/systemd/system/tmp /lib/systemd/system/docker.service
systemctl daemon-reload
systemctl restart docker.service
docker run -d -p 5000:5000 --restart=always --name registry registry:2

4
deploy/flannel_setup.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
## Apply Flannel CNI plugin
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/master/Documentation/kube-flannel.yml

8
deploy/gloo_setup.sh Normal file
View File

@ -0,0 +1,8 @@
#!/usr/bin/env bash
kubectl apply -f https://raw.githubusercontent.com/google/metallb/v0.7.3/manifests/metallb.yaml
curl -sL https://run.solo.io/gloo/install | sh
export PATH=$HOME/.gloo/bin:$PATH
glooctl install ingress

13
deploy/kafka_pv.yml Normal file
View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: datadir
labels:
kubeless: kafka
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 1Gi
hostPath:
path: "/root/paprika-k/"

View File

@ -0,0 +1,5 @@
#!/bin/bash
kubectl create -f kafka_pv.yml
kubectl create -f zoo_pv.yml
export RELEASE=$(curl -s https://api.github.com/repos/kubeless/kafka-trigger/releases/latest | grep tag_name | cut -d '"' -f 4)
kubectl create -f https://github.com/kubeless/kafka-trigger/releases/download/$RELEASE/kafka-zookeeper-$RELEASE.yaml

17
deploy/kubeless_setup.sh Normal file
View File

@ -0,0 +1,17 @@
#!/bin/bash
RELEASE=$(curl -s https://api.github.com/repos/kubeless/kubeless/releases/latest | grep tag_name | cut -d '"' -f 4)
kubectl create ns kubeless
kubectl create -f https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless-$RELEASE.yaml
#kubectl create -f https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless-non-rbac-$RELEASE.yaml
apt install -y unzip
#kubeless command
OS=$(uname -s| tr '[:upper:]' '[:lower:]')
curl -OL https://github.com/kubeless/kubeless/releases/download/$RELEASE/kubeless_$OS-amd64.zip && \
unzip kubeless_$OS-amd64.zip && \
sudo mv bundles/kubeless_$OS-amd64/kubeless /usr/local/bin/
#Ingress nginx
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/mandatory.yaml
kubectl apply -f https://raw.githubusercontent.com/kubernetes/ingress-nginx/master/deploy/provider/baremetal/service-nodeport.yaml

View File

@ -0,0 +1,3 @@
#!/bin/bash
kubectl create -f https://raw.githubusercontent.com/kubeless/kubeless-ui/master/k8s.yaml

View File

@ -0,0 +1,23 @@
#!/bin/bash
#Gen certificates
mkdir -p certs
cd certs
CERT_DIR=$PWD
openssl genrsa -des3 -passout pass:x -out dashboard.pass.key 2048
openssl rsa -passin pass:x -in dashboard.pass.key -out dashboard.key
rm dashboard.pass.key
openssl req -new -key dashboard.key -out dashboard.csr -subj "/C=US/ST=Denial/L=Springfield/O=Dis/CN=www.example.com"
openssl x509 -req -sha256 -days 365 -in dashboard.csr -signkey dashboard.key -out dashboard.crt
kubectl create secret generic kubernetes-dashboard-certs --from-file=$CERT_DIR -n kube-system
cd ..
#Deploy the dashboard
#wget https://raw.githubusercontent.com/kubernetes/dashboard/master/src/deploy/recommended/kubernetes-dashboard.yaml
wget https://raw.githubusercontent.com/kubernetes/dashboard/master/aio/deploy/recommended/kubernetes-dashboard.yaml
sed -i '176i\ type: LoadBalancer' kubernetes-dashboard.yaml
kubectl apply -f kubernetes-dashboard.yaml
#Token based dashboard authentication
kubectl create serviceaccount k8sadmin -n kube-system
kubectl create clusterrolebinding k8sadmin --clusterrole=cluster-admin --serviceaccount=kube-system:k8sadmin

View File

@ -0,0 +1,93 @@
#!/bin/bash
# Setting all parameters
NODE_TYPE=$1
INTERNAL=!$2
MASTER_IP=$3
## Parameters for master node installation
if [ "$NODE_TYPE" == "master" ]
then
if [ "$#" -lt 4 ]; then
POD_NETWORK_ARG=""
else
POD_NETWORK_ARG="--pod-network-cidr=$4"
fi
# Parameters for worker node installation
elif [ "$NODE_TYPE" == "worker" ]
then
TOKEN=$4
HASH=$5
fi
#Installing Docker
DOCKER_INSTALLED=$(which docker)
if [ "$DOCKER_INSTALLED" = "" ]
then
apt-get remove docker docker-engine docker.io
apt-get update
apt-get install -y apt-transport-https ca-certificates curl software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -
add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
apt-get update
apt-get install -y docker-ce
fi
#Installing Kubernetes
KUBERNETES_INSTALLED=$(which kubeadm)
if [ "$KUBERNETES_INSTALLED" = "" ]
then
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
touch /etc/apt/sources.list.d/kubernetes.list
chmod 666 /etc/apt/sources.list.d/kubernetes.list
echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" > /etc/apt/sources.list.d/kubernetes.list
apt-get update
apt-get install -y kubelet kubeadm kubectl kubernetes-cni
fi
#Disabling swap for Kubernetes
sysctl net.bridge.bridge-nf-call-iptables=1 > /dev/null
swapoff -a
# Initialize Kubernetes as Master node
if [ "$NODE_TYPE" == "master" ]
then
## Set master node for internal network
if [ $INTERNAL ]; then
touch /etc/default/kubelet
echo "KUBELET_EXTRA_ARGS=--node-ip=$MASTER_IP" > /etc/default/kubelet
fi
## Init Kubernetes
kubeadm init --ignore-preflight-errors=SystemVerification \
--apiserver-advertise-address=$MASTER_IP $POD_NETWORK_ARG
mkdir -p $HOME/.kube
cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
chown $(id -u):$(id -g) $HOME/.kube/config
echo "[master:$(hostname -s)] Node is up and running on $MASTER_IP"
# Initialize Kubernetes as Worker node
elif [ "$NODE_TYPE" = "worker" ]
then
## Set worker node for internal network
if [ $INTERNAL ]; then
IP=$(grep -oP \
'(?<=src )[^ ]*' \
<(grep -f <(ls -l /sys/class/net | grep pci | awk '{print $9}') \
<(ip ro sh) |
grep -v $(ip ro sh | grep default | awk '{print $5}')) |
head -1)
touch /etc/default/kubelet
echo "KUBELET_EXTRA_ARGS=--node-ip=$IP" > /etc/default/kubelet
else
IP=$(grep -oP '(?<=src )[^ ]*' <(ip ro sh | grep default))
fi
## Join to Kubernetes Master node
kubeadm join $MASTER_IP --token $TOKEN --discovery-token-ca-cert-hash $HASH \
--ignore-preflight-errors=SystemVerification
echo "[worker:$(hostname -s)] Client ($IP) joined to Master ($MASTER_IP)"
else
echo "Invalid argument"
fi

5
deploy/metric_setup.sh Normal file
View File

@ -0,0 +1,5 @@
git clone https://github.com/kubernetes-incubator/metrics-server.git
sed -i '34i\ command:\' metrics-server/deploy/1.8+/metrics-server-deployment.yaml
sed -i '35i\ - /metrics-server\' metrics-server/deploy/1.8+/metrics-server-deployment.yaml
sed -i '36i\ - --kubelet-insecure-tls\' metrics-server/deploy/1.8+/metrics-server-deployment.yaml
kubectl create -f metrics-server/deploy/1.8+/

4
deploy/weavenet_setup.sh Normal file
View File

@ -0,0 +1,4 @@
#!/bin/bash
## Apply WeaveNet CNI plugin
kubectl apply -f "https://cloud.weave.works/k8s/net?k8s-version=$(kubectl version | base64 | tr -d '\n')"

13
deploy/zoo_pv.yml Normal file
View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: PersistentVolume
metadata:
name: zookeeper
labels:
kubeless: zookeeper
spec:
accessModes:
- ReadWriteOnce
capacity:
storage: 1Gi
hostPath:
path: "/root/paprika-z/"