kubespray 2.24 추가

This commit is contained in:
변정훈
2024-02-16 17:08:09 +09:00
parent 1fa9b0df4b
commit f69d904725
1423 changed files with 89069 additions and 2 deletions

View File

@@ -0,0 +1,10 @@
---
multus_conf_file: "auto"
multus_cni_conf_dir_host: "/etc/cni/net.d"
multus_cni_bin_dir_host: "/opt/cni/bin"
multus_cni_run_dir_host: "/run"
multus_cni_conf_dir: "{{ ('/host', multus_cni_conf_dir_host) | join }}"
multus_cni_bin_dir: "{{ ('/host', multus_cni_bin_dir_host) | join }}"
multus_cni_run_dir: "{{ ('/host', multus_cni_run_dir_host) | join }}"
multus_cni_version: "0.4.0"
multus_kubeconfig_file_host: "{{ (multus_cni_conf_dir_host, '/multus.d/multus.kubeconfig') | join }}"

View File

@@ -0,0 +1,28 @@
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: multus
rules:
- apiGroups: ["k8s.cni.cncf.io"]
resources:
- '*'
verbs:
- '*'
- apiGroups:
- ""
resources:
- pods
- pods/status
verbs:
- get
- update
- apiGroups:
- ""
- events.k8s.io
resources:
- events
verbs:
- create
- patch
- update

View File

@@ -0,0 +1,13 @@
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: multus
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: multus
subjects:
- kind: ServiceAccount
name: multus
namespace: kube-system

View File

@@ -0,0 +1,45 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: network-attachment-definitions.k8s.cni.cncf.io
spec:
group: k8s.cni.cncf.io
scope: Namespaced
names:
plural: network-attachment-definitions
singular: network-attachment-definition
kind: NetworkAttachmentDefinition
shortNames:
- net-attach-def
versions:
- name: v1
served: true
storage: true
schema:
openAPIV3Schema:
description: 'NetworkAttachmentDefinition is a CRD schema specified by the Network Plumbing
Working Group to express the intent for attaching pods to one or more logical or physical
networks. More information available at: https://github.com/k8snetworkplumbingwg/multi-net-spec'
type: object
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this represen
tation of an object. Servers should convert recognized schemas to the
latest internal value, and may reject unrecognized values. More info:
https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: 'NetworkAttachmentDefinition spec defines the desired state of a network attachment'
type: object
properties:
config:
description: 'NetworkAttachmentDefinition config is a JSON-formatted CNI configuration'
type: string

View File

@@ -0,0 +1,6 @@
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: multus
namespace: kube-system

View File

@@ -0,0 +1,3 @@
---
dependencies:
- role: network_plugin/cni

View File

@@ -0,0 +1,36 @@
---
- name: Multus | Copy manifest files
copy:
src: "{{ item.file }}"
dest: "{{ kube_config_dir }}"
mode: 0644
with_items:
- {name: multus-crd, file: multus-crd.yml, type: customresourcedefinition}
- {name: multus-serviceaccount, file: multus-serviceaccount.yml, type: serviceaccount}
- {name: multus-clusterrole, file: multus-clusterrole.yml, type: clusterrole}
- {name: multus-clusterrolebinding, file: multus-clusterrolebinding.yml, type: clusterrolebinding}
register: multus_manifest_1
when: inventory_hostname == groups['kube_control_plane'][0]
- name: Multus | Check container engine type
set_fact:
container_manager_types: "{{ ansible_play_hosts_all | map('extract', hostvars, ['container_manager']) | list | unique }}"
- name: Multus | Copy manifest templates
template:
src: multus-daemonset.yml.j2
dest: "{{ kube_config_dir }}/{{ item.file }}"
mode: 0644
with_items:
- {name: multus-daemonset-containerd, file: multus-daemonset-containerd.yml, type: daemonset, engine: containerd }
- {name: multus-daemonset-docker, file: multus-daemonset-docker.yml, type: daemonset, engine: docker }
- {name: multus-daemonset-crio, file: multus-daemonset-crio.yml, type: daemonset, engine: crio }
register: multus_manifest_2
vars:
query: "*|[?container_manager=='{{ container_manager }}']|[0].inventory_hostname"
vars_from_node: "{{ hostvars | json_query(query) }}"
delegate_to: "{{ groups['kube_control_plane'][0] }}"
when:
- item.engine in container_manager_types
- hostvars[inventory_hostname].container_manager == item.engine
- inventory_hostname == vars_from_node

View File

@@ -0,0 +1,79 @@
---
kind: DaemonSet
apiVersion: apps/v1
metadata:
{% if container_manager_types | length >= 2 %}
name: kube-multus-{{ container_manager }}-{{ image_arch }}
{% else %}
name: kube-multus-ds-{{ image_arch }}
{% endif %}
namespace: kube-system
labels:
tier: node
app: multus
spec:
selector:
matchLabels:
tier: node
app: multus
template:
metadata:
labels:
tier: node
app: multus
spec:
hostNetwork: true
dnsPolicy: ClusterFirstWithHostNet
nodeSelector:
kubernetes.io/arch: {{ image_arch }}
{% if container_manager_types | length >= 2 %}
kubespray.io/container_manager: {{ container_manager }}
{% endif %}
tolerations:
- operator: Exists
serviceAccountName: multus
containers:
- name: kube-multus
image: {{ multus_image_repo }}:{{ multus_image_tag }}
command: ["/entrypoint.sh"]
args:
- "--cni-conf-dir={{ multus_cni_conf_dir }}"
- "--cni-bin-dir={{ multus_cni_bin_dir }}"
- "--multus-conf-file={{ multus_conf_file }}"
- "--multus-kubeconfig-file-host={{ multus_kubeconfig_file_host }}"
- "--cni-version={{ multus_cni_version }}"
resources:
requests:
cpu: "100m"
memory: "90Mi"
limits:
cpu: "100m"
memory: "90Mi"
securityContext:
privileged: true
{% if container_manager == 'crio' %}
capabilities:
add: ["SYS_ADMIN"]
{% endif %}
volumeMounts:
{% if container_manager == 'crio' %}
- name: run
mountPath: {{ multus_cni_run_dir }}
mountPropagation: HostToContainer
{% endif %}
- name: cni
mountPath: {{ multus_cni_conf_dir }}
- name: cnibin
mountPath: {{ multus_cni_bin_dir }}
volumes:
{% if container_manager == 'crio' %}
- name: run
hostPath:
path: {{ multus_cni_run_dir_host }}
{% endif %}
- name: cni
hostPath:
path: {{ multus_cni_conf_dir_host }}
- name: cnibin
hostPath:
path: {{ multus_cni_bin_dir_host }}