2017-12-30 20:19:50 +08:00
|
|
|
---
|
2019-10-19 22:25:42 +08:00
|
|
|
apiVersion: policy/v1beta1
|
|
|
|
kind: PodSecurityPolicy
|
|
|
|
metadata:
|
|
|
|
name: psp.flannel.unprivileged
|
|
|
|
annotations:
|
|
|
|
seccomp.security.alpha.kubernetes.io/allowedProfileNames: docker/default
|
|
|
|
seccomp.security.alpha.kubernetes.io/defaultProfileName: docker/default
|
|
|
|
apparmor.security.beta.kubernetes.io/allowedProfileNames: runtime/default
|
|
|
|
apparmor.security.beta.kubernetes.io/defaultProfileName: runtime/default
|
|
|
|
spec:
|
|
|
|
privileged: false
|
|
|
|
volumes:
|
2021-12-30 13:43:37 +08:00
|
|
|
- configMap
|
|
|
|
- secret
|
|
|
|
- emptyDir
|
|
|
|
- hostPath
|
2019-10-19 22:25:42 +08:00
|
|
|
allowedHostPaths:
|
2021-12-30 13:43:37 +08:00
|
|
|
- pathPrefix: "/etc/cni/net.d"
|
|
|
|
- pathPrefix: "/etc/kube-flannel"
|
|
|
|
- pathPrefix: "/run/flannel"
|
2019-10-19 22:25:42 +08:00
|
|
|
readOnlyRootFilesystem: false
|
|
|
|
# Users and groups
|
|
|
|
runAsUser:
|
|
|
|
rule: RunAsAny
|
|
|
|
supplementalGroups:
|
|
|
|
rule: RunAsAny
|
|
|
|
fsGroup:
|
|
|
|
rule: RunAsAny
|
|
|
|
# Privilege Escalation
|
|
|
|
allowPrivilegeEscalation: false
|
|
|
|
defaultAllowPrivilegeEscalation: false
|
|
|
|
# Capabilities
|
2021-12-30 13:43:37 +08:00
|
|
|
allowedCapabilities: ['NET_ADMIN', 'NET_RAW']
|
2019-10-19 22:25:42 +08:00
|
|
|
defaultAddCapabilities: []
|
|
|
|
requiredDropCapabilities: []
|
|
|
|
# Host namespaces
|
|
|
|
hostPID: false
|
|
|
|
hostIPC: false
|
|
|
|
hostNetwork: true
|
|
|
|
hostPorts:
|
|
|
|
- min: 0
|
|
|
|
max: 65535
|
|
|
|
# SELinux
|
|
|
|
seLinux:
|
2021-12-30 13:43:37 +08:00
|
|
|
# SELinux is unused in CaaSP
|
2019-10-19 22:25:42 +08:00
|
|
|
rule: 'RunAsAny'
|
|
|
|
---
|
2017-12-30 20:19:50 +08:00
|
|
|
kind: ClusterRole
|
2019-10-19 22:25:42 +08:00
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
2017-12-30 20:19:50 +08:00
|
|
|
metadata:
|
|
|
|
name: flannel
|
|
|
|
rules:
|
2021-12-30 13:43:37 +08:00
|
|
|
- apiGroups: ['policy']
|
|
|
|
resources: ['podsecuritypolicies']
|
|
|
|
verbs: ['use']
|
|
|
|
resourceNames: ['psp.flannel.unprivileged']
|
|
|
|
- apiGroups:
|
|
|
|
- ""
|
|
|
|
resources:
|
|
|
|
- pods
|
|
|
|
verbs:
|
|
|
|
- get
|
|
|
|
- apiGroups:
|
|
|
|
- ""
|
|
|
|
resources:
|
|
|
|
- nodes
|
|
|
|
verbs:
|
|
|
|
- list
|
|
|
|
- watch
|
|
|
|
- apiGroups:
|
|
|
|
- ""
|
|
|
|
resources:
|
|
|
|
- nodes/status
|
|
|
|
verbs:
|
|
|
|
- patch
|
2017-12-30 20:19:50 +08:00
|
|
|
---
|
|
|
|
kind: ClusterRoleBinding
|
2019-10-19 22:25:42 +08:00
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
2017-12-30 20:19:50 +08:00
|
|
|
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",
|
2019-10-19 22:25:42 +08:00
|
|
|
"cniVersion": "0.3.1",
|
2017-12-30 20:19:50 +08:00
|
|
|
"plugins": [
|
|
|
|
{
|
|
|
|
"type": "flannel",
|
|
|
|
"delegate": {
|
|
|
|
"hairpinMode": true,
|
|
|
|
"isDefaultGateway": true
|
|
|
|
}
|
|
|
|
},
|
|
|
|
{
|
|
|
|
"type": "portmap",
|
|
|
|
"capabilities": {
|
|
|
|
"portMappings": true
|
|
|
|
}
|
|
|
|
}
|
|
|
|
]
|
|
|
|
}
|
|
|
|
net-conf.json: |
|
|
|
|
{
|
2018-01-02 22:12:51 +08:00
|
|
|
"Network": "{{ CLUSTER_CIDR }}",
|
2017-12-30 20:19:50 +08:00
|
|
|
"Backend": {
|
2019-07-29 14:09:17 +08:00
|
|
|
{% if FLANNEL_BACKEND == "vxlan" and DIRECT_ROUTING %}
|
|
|
|
"DirectRouting": true,
|
|
|
|
{% endif %}
|
2018-01-04 22:50:09 +08:00
|
|
|
"Type": "{{ FLANNEL_BACKEND }}"
|
2017-12-30 20:19:50 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
---
|
2019-10-19 22:25:42 +08:00
|
|
|
apiVersion: apps/v1
|
2017-12-30 20:19:50 +08:00
|
|
|
kind: DaemonSet
|
|
|
|
metadata:
|
2021-12-30 13:43:37 +08:00
|
|
|
name: kube-flannel-ds
|
2017-12-30 20:19:50 +08:00
|
|
|
namespace: kube-system
|
|
|
|
labels:
|
|
|
|
tier: node
|
|
|
|
app: flannel
|
|
|
|
spec:
|
2019-10-19 22:25:42 +08:00
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
app: flannel
|
2017-12-30 20:19:50 +08:00
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
tier: node
|
|
|
|
app: flannel
|
|
|
|
spec:
|
2019-10-19 22:25:42 +08:00
|
|
|
affinity:
|
|
|
|
nodeAffinity:
|
|
|
|
requiredDuringSchedulingIgnoredDuringExecution:
|
|
|
|
nodeSelectorTerms:
|
2021-12-30 13:43:37 +08:00
|
|
|
- matchExpressions:
|
|
|
|
- key: kubernetes.io/os
|
|
|
|
operator: In
|
|
|
|
values:
|
|
|
|
- linux
|
2017-12-30 20:19:50 +08:00
|
|
|
hostNetwork: true
|
2021-12-30 13:43:37 +08:00
|
|
|
priorityClassName: system-node-critical
|
2017-12-30 20:19:50 +08:00
|
|
|
tolerations:
|
2019-02-15 14:47:43 +08:00
|
|
|
- operator: Exists
|
2017-12-30 20:19:50 +08:00
|
|
|
effect: NoSchedule
|
|
|
|
serviceAccountName: flannel
|
|
|
|
initContainers:
|
|
|
|
- name: install-cni
|
2019-02-15 14:47:43 +08:00
|
|
|
image: {{ flanneld_image }}
|
2017-12-30 20:19:50 +08:00
|
|
|
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
|
2018-06-09 17:57:17 +08:00
|
|
|
image: {{ flanneld_image }}
|
2017-12-30 20:19:50 +08:00
|
|
|
command:
|
|
|
|
- /opt/bin/flanneld
|
|
|
|
args:
|
|
|
|
- --ip-masq
|
|
|
|
- --kube-subnet-mgr
|
|
|
|
resources:
|
|
|
|
requests:
|
|
|
|
cpu: "100m"
|
|
|
|
memory: "50Mi"
|
|
|
|
limits:
|
|
|
|
cpu: "100m"
|
|
|
|
memory: "50Mi"
|
|
|
|
securityContext:
|
2019-10-19 22:25:42 +08:00
|
|
|
privileged: false
|
|
|
|
capabilities:
|
2021-12-30 13:43:37 +08:00
|
|
|
add: ["NET_ADMIN", "NET_RAW"]
|
2017-12-30 20:19:50 +08:00
|
|
|
env:
|
|
|
|
- name: POD_NAME
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: metadata.name
|
|
|
|
- name: POD_NAMESPACE
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: metadata.namespace
|
|
|
|
volumeMounts:
|
|
|
|
- name: run
|
2019-10-19 22:25:42 +08:00
|
|
|
mountPath: /run/flannel
|
2017-12-30 20:19:50 +08:00
|
|
|
- name: flannel-cfg
|
|
|
|
mountPath: /etc/kube-flannel/
|
|
|
|
volumes:
|
2021-12-30 13:43:37 +08:00
|
|
|
- name: run
|
|
|
|
hostPath:
|
|
|
|
path: /run/flannel
|
|
|
|
- name: cni
|
|
|
|
hostPath:
|
|
|
|
path: /etc/cni/net.d
|
|
|
|
- name: flannel-cfg
|
|
|
|
configMap:
|
|
|
|
name: kube-flannel-cfg
|