Browse Source
Merge pull request #588 from adidenko/canal-support
Merge pull request #588 from adidenko/canal-support
Adding support for canal network pluginpull/587/merge
committed by
GitHub
17 changed files with 288 additions and 9 deletions
Split View
Diff Options
-
3cluster.yml
-
17roles/download/defaults/main.yml
-
4roles/kubernetes-apps/ansible/tasks/main.yaml
-
0roles/kubernetes-apps/lib/library/kube.py
-
17roles/kubernetes-apps/network_plugin/canal/tasks/main.yaml
-
4roles/kubernetes-apps/network_plugin/meta/main.yml
-
7roles/kubernetes/node/tasks/main.yml
-
15roles/kubernetes/node/templates/cni-canal.conf.j2
-
2roles/kubernetes/node/templates/kubelet.j2
-
2roles/kubernetes/preinstall/tasks/main.yml
-
11roles/network_plugin/canal/defaults/main.yml
-
12roles/network_plugin/canal/meta/main.yml
-
32roles/network_plugin/canal/tasks/main.yml
-
22roles/network_plugin/canal/templates/canal-config.yml.j2
-
146roles/network_plugin/canal/templates/canal-node.yml.j2
-
1roles/network_plugin/canal/templates/network.json.j2
-
2roles/network_plugin/meta/main.yml
@ -0,0 +1,17 @@ |
|||
- name: Create canal ConfigMap |
|||
run_once: true |
|||
kube: |
|||
name: "canal-config" |
|||
kubectl: "{{bin_dir}}/kubectl" |
|||
filename: "/etc/kubernetes/canal-config.yaml" |
|||
resource: "configmap" |
|||
namespace: "kube-system" |
|||
|
|||
- name: Start flannel and calico-node |
|||
run_once: true |
|||
kube: |
|||
name: "canal-node" |
|||
kubectl: "{{bin_dir}}/kubectl" |
|||
filename: "/etc/kubernetes/canal-node.yaml" |
|||
resource: "ds" |
|||
namespace: "kube-system" |
@ -0,0 +1,4 @@ |
|||
--- |
|||
dependencies: |
|||
- role: kubernetes-apps/network_plugin/canal |
|||
when: kube_network_plugin == 'canal' |
@ -0,0 +1,15 @@ |
|||
{ |
|||
"name": "canal-k8s-network", |
|||
"type": "flannel", |
|||
"delegate": { |
|||
"type": "calico", |
|||
"etcd_endpoints": "{{ etcd_access_endpoint }}", |
|||
"log_level": "info", |
|||
"policy": { |
|||
"type": "k8s" |
|||
}, |
|||
"kubernetes": { |
|||
"kubeconfig": "{{ kube_config_dir }}/node-kubeconfig.yaml" |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,11 @@ |
|||
# The interface used by canal for host <-> host communication. |
|||
# If left blank, then the interface is chosing using the node's |
|||
# default route. |
|||
canal_iface: "" |
|||
|
|||
# Whether or not to masquerade traffic to destinations not within |
|||
# the pod network. |
|||
canal_masquerade: "true" |
|||
|
|||
# Log-level |
|||
canal_log_level: "info" |
@ -0,0 +1,12 @@ |
|||
--- |
|||
dependencies: |
|||
- role: download |
|||
file: "{{ downloads.flannel_server_helper }}" |
|||
- role: download |
|||
file: "{{ downloads.flannel }}" |
|||
- role: download |
|||
file: "{{ downloads.calico_node }}" |
|||
- role: download |
|||
file: "{{ downloads.calicoctl }}" |
|||
- role: download |
|||
file: "{{ downloads.calico_cni }}" |
@ -0,0 +1,32 @@ |
|||
--- |
|||
- name: Canal | Write flannel configuration |
|||
template: |
|||
src: network.json.j2 |
|||
dest: /etc/flannel-network.json |
|||
backup: yes |
|||
|
|||
- name: Canal | Write canal configmap |
|||
template: |
|||
src: canal-config.yml.j2 |
|||
dest: /etc/kubernetes/canal-config.yaml |
|||
|
|||
- name: Canal | Write canal node configuration |
|||
template: |
|||
src: canal-node.yml.j2 |
|||
dest: /etc/kubernetes/canal-node.yaml |
|||
|
|||
- name: Canal | Copy cni plugins from hyperkube |
|||
command: "/usr/bin/docker run --rm -v /opt/cni/bin:/cnibindir {{ hyperkube_image_repo }}:{{ hyperkube_image_tag }} /usr/bin/rsync -a /opt/cni/bin/ /cnibindir/" |
|||
register: cni_task_result |
|||
until: cni_task_result.rc == 0 |
|||
retries: 4 |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
changed_when: false |
|||
|
|||
- name: Canal | Copy cni plugins from calico/cni |
|||
command: "/usr/bin/docker run --rm -v /opt/cni/bin:/cnibindir {{ calico_cni_image_repo }}:{{ calico_cni_image_tag }} sh -c 'cp -a /opt/cni/bin/* /cnibindir/'" |
|||
register: cni_task_result |
|||
until: cni_task_result.rc == 0 |
|||
retries: 4 |
|||
delay: "{{ retry_stagger | random + 3 }}" |
|||
changed_when: false |
@ -0,0 +1,22 @@ |
|||
# This ConfigMap can be used to configure a self-hosted Canal installation. |
|||
# See `canal.yaml` for an example of a Canal deployment which uses |
|||
# the config in this ConfigMap. |
|||
kind: ConfigMap |
|||
apiVersion: v1 |
|||
metadata: |
|||
name: canal-config |
|||
data: |
|||
# Configure this with the location of your etcd cluster. |
|||
etcd_endpoints: "{{ etcd_access_endpoint }}" |
|||
|
|||
# The interface used by canal for host <-> host communication. |
|||
# If left blank, then the interface is chosing using the node's |
|||
# default route. |
|||
flanneld_iface: "{{ canal_iface }}" |
|||
|
|||
# Whether or not to masquerade traffic to destinations not within |
|||
# the pod network. |
|||
masquerade: "{{ canal_masquerade }}" |
|||
|
|||
# Cluster name for Flannel etcd path |
|||
cluster_name: "{{ cluster_name }}" |
@ -0,0 +1,146 @@ |
|||
--- |
|||
kind: DaemonSet |
|||
apiVersion: extensions/v1beta1 |
|||
metadata: |
|||
name: canal-node |
|||
labels: |
|||
k8s-app: canal-node |
|||
spec: |
|||
selector: |
|||
matchLabels: |
|||
k8s-app: canal-node |
|||
template: |
|||
metadata: |
|||
annotations: |
|||
scheduler.alpha.kubernetes.io/critical-pod: '' |
|||
scheduler.alpha.kubernetes.io/tolerations: '[{"key":"CriticalAddonsOnly", "operator":"Exists"}]' |
|||
labels: |
|||
k8s-app: canal-node |
|||
spec: |
|||
hostNetwork: true |
|||
volumes: |
|||
# Used by flannel-server-helper |
|||
- name: "networkconfig" |
|||
hostPath: |
|||
path: "/etc/flannel-network.json" |
|||
# Used by calico/node. |
|||
- name: lib-modules |
|||
hostPath: |
|||
path: /lib/modules |
|||
- name: var-run-calico |
|||
hostPath: |
|||
path: /var/run/calico |
|||
# Used to install CNI. |
|||
- name: cni-bin-dir |
|||
hostPath: |
|||
path: /opt/cni/bin |
|||
- name: cni-net-dir |
|||
hostPath: |
|||
path: /etc/cni/net.d |
|||
# Used by flannel daemon. |
|||
- name: run-flannel |
|||
hostPath: |
|||
path: /run/flannel |
|||
- name: resolv |
|||
hostPath: |
|||
path: /etc/resolv.conf |
|||
containers: |
|||
- name: "flannel-server-helper" |
|||
image: "{{ flannel_server_helper_image_repo }}:{{ flannel_server_helper_image_tag }}" |
|||
env: |
|||
# Cluster name |
|||
- name: CLUSTER_NAME |
|||
valueFrom: |
|||
configMapKeyRef: |
|||
name: canal-config |
|||
key: cluster_name |
|||
# The location of the etcd cluster. |
|||
- name: FLANNELD_ETCD_ENDPOINTS |
|||
valueFrom: |
|||
configMapKeyRef: |
|||
name: canal-config |
|||
key: etcd_endpoints |
|||
args: |
|||
- "--network-config=/etc/flannel-network.json" |
|||
- "--etcd-prefix=/$(CLUSTER_NAME)/network" |
|||
- "--etcd-server=$(FLANNELD_ETCD_ENDPOINTS)" |
|||
volumeMounts: |
|||
- name: "networkconfig" |
|||
mountPath: "/etc/flannel-network.json" |
|||
imagePullPolicy: "Always" |
|||
# Runs the flannel daemon to enable vxlan networking between |
|||
# container hosts. |
|||
- name: flannel |
|||
image: "{{ flannel_image_repo }}:{{ flannel_image_tag }}" |
|||
env: |
|||
# Cluster name |
|||
- name: CLUSTER_NAME |
|||
valueFrom: |
|||
configMapKeyRef: |
|||
name: canal-config |
|||
key: cluster_name |
|||
# The location of the etcd cluster. |
|||
- name: FLANNELD_ETCD_ENDPOINTS |
|||
valueFrom: |
|||
configMapKeyRef: |
|||
name: canal-config |
|||
key: etcd_endpoints |
|||
# The interface flannel should run on. |
|||
- name: FLANNELD_IFACE |
|||
valueFrom: |
|||
configMapKeyRef: |
|||
name: canal-config |
|||
key: flanneld_iface |
|||
# Perform masquerade on traffic leaving the pod cidr. |
|||
- name: FLANNELD_IP_MASQ |
|||
valueFrom: |
|||
configMapKeyRef: |
|||
name: canal-config |
|||
key: masquerade |
|||
# Set etcd-prefix |
|||
- name: DOCKER_OPT_ETCD_PREFIX |
|||
value: "-etcd-prefix=/$(CLUSTER_NAME)/network" |
|||
# Write the subnet.env file to the mounted directory. |
|||
- name: FLANNELD_SUBNET_FILE |
|||
value: "/run/flannel/subnet.env" |
|||
command: |
|||
- "/bin/sh" |
|||
- "-c" |
|||
- "/opt/bin/flanneld -etcd-prefix /$(CLUSTER_NAME)/network" |
|||
ports: |
|||
- hostPort: 10253 |
|||
containerPort: 10253 |
|||
securityContext: |
|||
privileged: true |
|||
volumeMounts: |
|||
- name: "resolv" |
|||
mountPath: "/etc/resolv.conf" |
|||
- name: "run-flannel" |
|||
mountPath: "/run/flannel" |
|||
# Runs calico/node container on each Kubernetes node. This |
|||
# container programs network policy and local routes on each |
|||
# host. |
|||
- name: calico-node |
|||
image: "{{ calico_node_image_repo }}:{{ calico_node_image_tag }}" |
|||
env: |
|||
# The location of the etcd cluster. |
|||
- name: ETCD_ENDPOINTS |
|||
valueFrom: |
|||
configMapKeyRef: |
|||
name: canal-config |
|||
key: etcd_endpoints |
|||
# Disable Calico BGP. Calico is simply enforcing policy. |
|||
- name: CALICO_NETWORKING |
|||
value: "false" |
|||
# Disable file logging so `kubectl logs` works. |
|||
- name: CALICO_DISABLE_FILE_LOGGING |
|||
value: "true" |
|||
securityContext: |
|||
privileged: true |
|||
volumeMounts: |
|||
- mountPath: /lib/modules |
|||
name: lib-modules |
|||
readOnly: true |
|||
- mountPath: /var/run/calico |
|||
name: var-run-calico |
|||
readOnly: false |
@ -0,0 +1 @@ |
|||
{ "Network": "{{ kube_pods_subnet }}", "SubnetLen": {{ kube_network_node_prefix }}, "Backend": { "Type": "{{ flannel_backend_type }}" } } |
Write
Preview
Loading…
Cancel
Save