Skip to content

Commit

Permalink
tidy up for the example configuration of k8s
Browse files Browse the repository at this point in the history
  • Loading branch information
chendave committed Nov 29, 2019
1 parent 7c39607 commit 2ecce13
Show file tree
Hide file tree
Showing 15 changed files with 85 additions and 47 deletions.
15 changes: 15 additions & 0 deletions k8s/demo/configmap/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: special-config
namespace: default
data:
special.how: very
---
apiVersion: v1
kind: ConfigMap
metadata:
name: env-config
namespace: default
data:
log_level: INFO
File renamed without changes.
15 changes: 9 additions & 6 deletions k8s/demo/nginx.yaml → k8s/demo/deployment/nginx.yaml
Original file line number Diff line number Diff line change
@@ -1,18 +1,21 @@
apiVersion: extensions/v1beta1
apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx0-deployment
name: nginx-deployment
labels:
app: nginx0-deployment
app: nginx
spec:
replicas: 2
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx0
app: nginx
spec:
containers:
- name: nginx
image: k8s.gcr.io/nginx:1.7.9
image: nginx:1.7.9
ports:
- containerPort: 80
File renamed without changes.
File renamed without changes.
14 changes: 0 additions & 14 deletions k8s/demo/myjob1.yaml

This file was deleted.

11 changes: 0 additions & 11 deletions k8s/demo/new.yml

This file was deleted.

16 changes: 0 additions & 16 deletions k8s/demo/nginx.yml

This file was deleted.

File renamed without changes.
9 changes: 9 additions & 0 deletions k8s/demo/role/role.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
namespace: default
name: pod-reader
rules:
- apiGroups: [""] # "" indicates the core API group
resources: ["pods"]
verbs: ["get", "watch", "list"]
52 changes: 52 additions & 0 deletions k8s/demo/scripts/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash

sudo swapoff -a

# install docker
sudo apt-get remove docker docker-engine docker.io containerd runc
sudo apt-get update
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
gnupg-agent \
software-properties-common


curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
sudo apt-key fingerprint 0EBFCD88

# on arm
sudo add-apt-repository \
"deb [arch=arm64] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) \
stable"
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
# do a sanity check
sudo docker run hello-world

# install kubeadm/kubectl
apt-get update && apt-get install -y apt-transport-https curl
curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | apt-key add -
cat <<EOF >/etc/apt/sources.list.d/kubernetes.list
deb https://apt.kubernetes.io/ kubernetes-xenial main
EOF
apt-get update
apt-get install -y kubelet kubeadm kubectl
apt-mark hold kubelet kubeadm kubectl

# setup cluster with kubeadm

# replace "10.169.40.58" with your host IP
kubeadm init --apiserver-advertise-address 10.169.40.58 --pod-network-cidr=10.244.0.0/16
kubectl apply -f https://raw.githubusercontent.com/coreos/flannel/62e44c867a2846fefb68bd5f178daf4da3095ccb/Documentation/kube-flannel.yml

# make it work for non-root user, might need to remove the cofig file
mkdir -p $HOME/.kube
sudo cp -i /etc/kubernetes/admin.conf $HOME/.kube/config
sudo chown $(id -u):$(id -g) $HOME/.kube/config


# join other nodes
#kubeadm join xxx --token xxx --discovery-token-ca-cert-hash xxx
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit 2ecce13

Please sign in to comment.