-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
291 additions
and
0 deletions.
There are no files selected for viewing
260 changes: 260 additions & 0 deletions
260
environments/crunchydata-k8s-centos/master/build/1_k8s_master.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,260 @@ | ||
echo '127.0.0.1 master' >> /etc/hosts | ||
hostname master && echo master > /etc/hostname | ||
hostnamectl set-hostname master | ||
|
||
cat <<EOF > /etc/yum.repos.d/kubernetes.repo | ||
[kubernetes] | ||
name=Kubernetes | ||
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 | ||
enabled=1 | ||
gpgcheck=1 | ||
repo_gpgcheck=1 | ||
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg | ||
exclude=kube* | ||
EOF | ||
|
||
# Set SELinux in permissive mode (effectively disabling it) | ||
setenforce 0 | ||
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config | ||
|
||
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes | ||
|
||
systemctl enable --now kubelet | ||
|
||
cat <<EOF > /etc/sysctl.d/k8s.conf | ||
net.bridge.bridge-nf-call-ip6tables = 1 | ||
net.bridge.bridge-nf-call-iptables = 1 | ||
EOF | ||
sysctl --system | ||
|
||
sudo kubectl completion bash | sudo tee -a /etc/bash_completion.d/kubectl | ||
echo Pulling Images; | ||
sudo kubeadm config images pull; | ||
sudo docker pull weaveworks/weave-kube:2.5.1 | ||
sudo docker pull weaveworks/weave-npc:2.5.1 | ||
|
||
cat <<EOF > /opt/launch-kubeadm.sh | ||
#!/bin/sh | ||
rm $HOME/.kube/config | ||
kubeadm reset -f || true | ||
mkdir -p /root/.kube | ||
kubeadm init --kubernetes-version $(kubeadm version -o short) --token=96771a.f608976060d16396 | ||
mkdir -p $HOME/.kube | ||
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config | ||
sudo chown $(id -u):$(id -g) $HOME/.kube/config | ||
kubectl apply -f /opt/weave-kube | ||
EOF | ||
|
||
chmod +x /opt/launch-kubeadm.sh | ||
|
||
cat <<EOF > /opt/weave-kube | ||
apiVersion: v1 | ||
kind: List | ||
items: | ||
- apiVersion: v1 | ||
kind: ServiceAccount | ||
metadata: | ||
name: weave-net | ||
labels: | ||
name: weave-net | ||
namespace: kube-system | ||
- apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRole | ||
metadata: | ||
name: weave-net | ||
labels: | ||
name: weave-net | ||
rules: | ||
- apiGroups: | ||
- '' | ||
resources: | ||
- pods | ||
- namespaces | ||
- nodes | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- extensions | ||
resources: | ||
- networkpolicies | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- 'networking.k8s.io' | ||
resources: | ||
- networkpolicies | ||
verbs: | ||
- get | ||
- list | ||
- watch | ||
- apiGroups: | ||
- '' | ||
resources: | ||
- nodes/status | ||
verbs: | ||
- patch | ||
- update | ||
- apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: ClusterRoleBinding | ||
metadata: | ||
name: weave-net | ||
labels: | ||
name: weave-net | ||
roleRef: | ||
kind: ClusterRole | ||
name: weave-net | ||
apiGroup: rbac.authorization.k8s.io | ||
subjects: | ||
- kind: ServiceAccount | ||
name: weave-net | ||
namespace: kube-system | ||
- apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: Role | ||
metadata: | ||
name: weave-net | ||
namespace: kube-system | ||
labels: | ||
name: weave-net | ||
rules: | ||
- apiGroups: | ||
- '' | ||
resources: | ||
- configmaps | ||
resourceNames: | ||
- weave-net | ||
verbs: | ||
- get | ||
- update | ||
- apiGroups: | ||
- '' | ||
resources: | ||
- configmaps | ||
verbs: | ||
- create | ||
- apiVersion: rbac.authorization.k8s.io/v1beta1 | ||
kind: RoleBinding | ||
metadata: | ||
name: weave-net | ||
namespace: kube-system | ||
labels: | ||
name: weave-net | ||
roleRef: | ||
kind: Role | ||
name: weave-net | ||
apiGroup: rbac.authorization.k8s.io | ||
subjects: | ||
- kind: ServiceAccount | ||
name: weave-net | ||
namespace: kube-system | ||
- apiVersion: extensions/v1beta1 | ||
kind: DaemonSet | ||
metadata: | ||
name: weave-net | ||
labels: | ||
name: weave-net | ||
namespace: kube-system | ||
spec: | ||
# Wait 5 seconds to let pod connect before rolling next pod | ||
minReadySeconds: 5 | ||
template: | ||
metadata: | ||
labels: | ||
name: weave-net | ||
spec: | ||
containers: | ||
- name: weave | ||
command: | ||
- /home/weave/launch.sh | ||
env: | ||
- name: HOSTNAME | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: spec.nodeName | ||
image: 'weaveworks/weave-kube:2.5.1' | ||
imagePullPolicy: Always | ||
readinessProbe: | ||
httpGet: | ||
host: 127.0.0.1 | ||
path: /status | ||
port: 6784 | ||
resources: | ||
requests: | ||
cpu: 10m | ||
securityContext: | ||
privileged: true | ||
volumeMounts: | ||
- name: weavedb | ||
mountPath: /weavedb | ||
- name: cni-bin | ||
mountPath: /host/opt | ||
- name: cni-bin2 | ||
mountPath: /host/home | ||
- name: cni-conf | ||
mountPath: /host/etc | ||
- name: dbus | ||
mountPath: /host/var/lib/dbus | ||
- name: lib-modules | ||
mountPath: /lib/modules | ||
- name: xtables-lock | ||
mountPath: /run/xtables.lock | ||
readOnly: false | ||
- name: weave-npc | ||
env: | ||
- name: HOSTNAME | ||
valueFrom: | ||
fieldRef: | ||
apiVersion: v1 | ||
fieldPath: spec.nodeName | ||
image: 'weaveworks/weave-npc:2.5.1' | ||
imagePullPolicy: Always | ||
#npc-args | ||
resources: | ||
requests: | ||
cpu: 10m | ||
securityContext: | ||
privileged: true | ||
volumeMounts: | ||
- name: xtables-lock | ||
mountPath: /run/xtables.lock | ||
readOnly: false | ||
hostNetwork: true | ||
hostPID: true | ||
restartPolicy: Always | ||
securityContext: | ||
seLinuxOptions: {} | ||
serviceAccountName: weave-net | ||
tolerations: | ||
- effect: NoSchedule | ||
operator: Exists | ||
volumes: | ||
- name: weavedb | ||
hostPath: | ||
path: /var/lib/weave | ||
- name: cni-bin | ||
hostPath: | ||
path: /opt | ||
- name: cni-bin2 | ||
hostPath: | ||
path: /home | ||
- name: cni-conf | ||
hostPath: | ||
path: /etc | ||
- name: dbus | ||
hostPath: | ||
path: /var/lib/dbus | ||
- name: lib-modules | ||
hostPath: | ||
path: /lib/modules | ||
- name: xtables-lock | ||
hostPath: | ||
path: /run/xtables.lock | ||
type: FileOrCreate | ||
updateStrategy: | ||
type: RollingUpdate | ||
EOF | ||
|
31 changes: 31 additions & 0 deletions
31
environments/crunchydata-k8s-centos/node01/build/1_k8s_node.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
echo '127.0.0.1 node01' >> /etc/hosts | ||
hostname node01 && echo node01 > /etc/hostname | ||
hostnamectl set-hostname node01 | ||
|
||
cat <<EOF > /etc/yum.repos.d/kubernetes.repo | ||
[kubernetes] | ||
name=Kubernetes | ||
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64 | ||
enabled=1 | ||
gpgcheck=1 | ||
repo_gpgcheck=1 | ||
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg | ||
exclude=kube* | ||
EOF | ||
|
||
# Set SELinux in permissive mode (effectively disabling it) | ||
setenforce 0 | ||
sed -i 's/^SELINUX=enforcing$/SELINUX=permissive/' /etc/selinux/config | ||
|
||
yum install -y kubelet kubeadm kubectl --disableexcludes=kubernetes | ||
|
||
systemctl enable --now kubelet | ||
|
||
cat <<EOF > /etc/sysctl.d/k8s.conf | ||
net.bridge.bridge-nf-call-ip6tables = 1 | ||
net.bridge.bridge-nf-call-iptables = 1 | ||
EOF | ||
sysctl --system | ||
sudo kubeadm config images pull | ||
sudo docker pull weaveworks/weave-kube:2.5.1 | ||
sudo docker pull weaveworks/weave-npc:2.5.1 |