Install Kubernetes 1.11 and go back to Ubuntu Xenial until Bionic is officially supported

This commit is contained in:
Paul-Henri Froidmont 2018-09-25 17:07:38 +02:00
parent 5acc7652a9
commit bf83e675f2
26 changed files with 765 additions and 7 deletions

View file

@ -0,0 +1,69 @@
global_defs {
{% if ansible_tun0 is defined %}
default_interface tun0
{% else %}
default_interface eth0
{% endif %}
}
vrrp_instance VI_1 {
{% if ansible_tun0 is defined %}
interface tun0
{% else %}
interface eth0
{% endif %}
track_interface {
{% if ansible_tun0 is defined %}
tun0
{% else %}
eth0
{% endif %}
}
{% if inventory_hostname == initial_master %}
state MASTER
priority 100
{% else %}
state BACKUP
priority 50
{% endif %}
virtual_router_id {{ router_id }}
nopreempt
unicast_peer {
{% for host in groups['k8s_masters'] %}
{{ hostvars[host]['vpn_ip'] }}
{% endfor %}
}
virtual_ipaddress {
{{ api_floating_ip }}/{{ api_floating_mask }}
}
authentication {
auth_type PASS
auth_pass d0cker
}
notify "/container/service/keepalived/assets/notify.sh"
}
virtual_server {{ api_floating_ip }} {{ api_floating_port }} {
delay_loop 10
protocol TCP
lb_algo rr
# Use direct routing
lb_kind DR
persistence_timeout 7200
{% for host in groups['k8s_masters'] %}
real_server {{ hostvars[host]['vpn_ip'] }} {{ api_floating_port }} {
weight 1
TCP_CHECK {
connect_timeout 5
connect_port 6443
}
}
{% endfor %}
}

View file

@ -0,0 +1,36 @@
apiVersion: v1
kind: Pod
metadata:
name: keepalived
namespace: kube-system
spec:
hostNetwork: true
volumes:
- hostPath:
path: /etc/keepalived/keepalived.conf
type: File
name: keepalived-config
containers:
- name: keepalived
image: chmod666/keepalived:latest
# if tag is latest imagePullPolicy is always
# but when keepalived is backup a proxy may have no connection to the internet
# to avoid keepalived not starting in that case, we're putting imagePullPolicy: IfNotPresent
# assuming the image was already be pulled at cluster creation. Neat.
imagePullPolicy: IfNotPresent
volumeMounts:
- mountPath: "/usr/local/etc/keepalived/keepalived.conf"
name: keepalived-config
securityContext:
capabilities:
add:
- NET_ADMIN
#env:
# - name: KEEPALIVED_INTERFACE
# value: tun0
# - name: KEEPALIVED_UNICAST_PEERS
# value: "#PYTHON2BASH:['{{ groups['masters'] | map('extract', hostvars, ['vpn_ip']) | join("', '") }}']"
# - name: KEEPALIVED_VIRTUAL_IPS
# value: "#PYTHON2BASH:['{{ api_floating_ip }}/{{ api_floating_mask }}']"
# - name: KEEPALIVED_PRIORITY
# value: "{{ groups['masters'].index(inventory_hostname) + 1 }}"

View file

@ -0,0 +1,160 @@
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: flannel
rules:
- apiGroups:
- ""
resources:
- pods
verbs:
- get
- apiGroups:
- ""
resources:
- nodes
verbs:
- list
- watch
- apiGroups:
- ""
resources:
- nodes/status
verbs:
- patch
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1beta1
metadata:
name: flannel
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: flannel
subjects:
- kind: ServiceAccount
name: flannel
namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: flannel
namespace: kube-system
---
kind: ConfigMap
apiVersion: v1
metadata:
name: kube-flannel-cfg
namespace: kube-system
labels:
tier: node
app: flannel
data:
cni-conf.json: |
{
"name": "cbr0",
"plugins": [
{
"type": "flannel",
"delegate": {
"hairpinMode": true,
"isDefaultGateway": true
}
},
{
"type": "portmap",
"capabilities": {
"portMappings": true
}
}
]
}
net-conf.json: |
{
"Network": "10.244.0.0/16",
"Backend": {
"Type": "vxlan"
}
}
---
apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
name: kube-flannel-ds
namespace: kube-system
labels:
tier: node
app: flannel
spec:
template:
metadata:
labels:
tier: node
app: flannel
spec:
hostNetwork: true
nodeSelector:
beta.kubernetes.io/arch: {{ kube_arch }}
tolerations:
- key: node-role.kubernetes.io/master
operator: Exists
effect: NoSchedule
serviceAccountName: flannel
initContainers:
- name: install-cni
image: quay.io/coreos/flannel:{{ cni_version }}-{{ kube_arch }}
command:
- cp
args:
- -f
- /etc/kube-flannel/cni-conf.json
- /etc/cni/net.d/10-flannel.conflist
volumeMounts:
- name: cni
mountPath: /etc/cni/net.d
- name: flannel-cfg
mountPath: /etc/kube-flannel/
containers:
- name: kube-flannel
image: quay.io/coreos/flannel:{{ cni_version }}-{{ kube_arch }}
command:
- /opt/bin/flanneld
args:
- --ip-masq
- --kube-subnet-mgr
- --iface={{ cni_interface.stdout | trim }}
resources:
requests:
cpu: "100m"
memory: "50Mi"
limits:
cpu: "100m"
memory: "50Mi"
securityContext:
privileged: true
env:
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
volumeMounts:
- name: run
mountPath: /run
- name: flannel-cfg
mountPath: /etc/kube-flannel/
volumes:
- name: run
hostPath:
path: /run
- name: cni
hostPath:
path: /etc/cni/net.d
- name: flannel-cfg
configMap:
name: kube-flannel-cfg

View file

@ -0,0 +1,27 @@
apiVersion: kubeadm.k8s.io/v1alpha2
kind: MasterConfiguration
api:
advertiseAddress: {{ api_floating_ip if groups.k8s_masters | length > 1 else hostvars[initial_master].vpn_ip }}
etcd:
external:
endpoints:
{% for host in groups['k8s_masters'] %}
- "http://{{ hostvars[host]['vpn_ip'] }}:2379"
{% endfor %}
networking:
podSubnet: "{{ pod_subnet }}"
kubernetesVersion: "{{ kubernetes_version }}"
apiServerCertSANs:
{% for host in groups['k8s_masters'] %}
- "{{ hostvars[host]['vpn_ip'] }}"
{% endfor %}
- "{{ api_floating_ip }}"
- "127.0.0.1"
bootstrapTokens:
- groups:
- system:bootstrappers:kubeadm:default-node-token
token: "{{ hostvars[initial_master].kubeadm_token }}"
ttl: 0s
usages:
- signing
- authentication

View file

@ -0,0 +1,2 @@
[Service]
Environment="KUBELET_EXTRA_ARGS=--fail-swap-on=false"