2020-06-30 06:11:59 +08:00
|
|
|
apiVersion: v1
|
|
|
|
kind: Namespace
|
|
|
|
metadata:
|
|
|
|
name: metallb-system
|
|
|
|
labels:
|
|
|
|
app: metallb
|
2023-02-06 17:27:01 +08:00
|
|
|
pod-security.kubernetes.io/audit: privileged
|
|
|
|
pod-security.kubernetes.io/enforce: privileged
|
|
|
|
pod-security.kubernetes.io/warn: privileged
|
2020-06-30 06:11:59 +08:00
|
|
|
---
|
|
|
|
apiVersion: v1
|
|
|
|
kind: ServiceAccount
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: controller
|
|
|
|
namespace: metallb-system
|
|
|
|
---
|
2021-05-12 20:22:17 +08:00
|
|
|
{% if metallb_speaker_enabled %}
|
2020-06-30 06:11:59 +08:00
|
|
|
apiVersion: v1
|
|
|
|
kind: ServiceAccount
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: speaker
|
|
|
|
namespace: metallb-system
|
2021-05-12 20:22:17 +08:00
|
|
|
{% endif %}
|
2020-06-30 06:11:59 +08:00
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: ClusterRole
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: metallb-system:controller
|
|
|
|
rules:
|
|
|
|
- apiGroups:
|
|
|
|
- ''
|
|
|
|
resources:
|
|
|
|
- services
|
|
|
|
verbs:
|
|
|
|
- get
|
|
|
|
- list
|
|
|
|
- watch
|
|
|
|
- apiGroups:
|
|
|
|
- ''
|
|
|
|
resources:
|
|
|
|
- services/status
|
|
|
|
verbs:
|
|
|
|
- update
|
|
|
|
- apiGroups:
|
|
|
|
- ''
|
|
|
|
resources:
|
|
|
|
- events
|
|
|
|
verbs:
|
|
|
|
- create
|
|
|
|
- patch
|
|
|
|
- apiGroups:
|
|
|
|
- policy
|
|
|
|
resourceNames:
|
|
|
|
- controller
|
|
|
|
resources:
|
|
|
|
- podsecuritypolicies
|
|
|
|
verbs:
|
|
|
|
- use
|
|
|
|
---
|
2021-05-12 20:22:17 +08:00
|
|
|
{% if metallb_speaker_enabled %}
|
2020-06-30 06:11:59 +08:00
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: ClusterRole
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: metallb-system:speaker
|
|
|
|
rules:
|
|
|
|
- apiGroups:
|
|
|
|
- ''
|
|
|
|
resources:
|
|
|
|
- services
|
|
|
|
- endpoints
|
|
|
|
- nodes
|
|
|
|
verbs:
|
|
|
|
- get
|
|
|
|
- list
|
|
|
|
- watch
|
2021-09-01 18:00:59 +08:00
|
|
|
- apiGroups: ["discovery.k8s.io"]
|
|
|
|
resources:
|
|
|
|
- endpointslices
|
|
|
|
verbs:
|
|
|
|
- get
|
|
|
|
- list
|
|
|
|
- watch
|
2020-06-30 06:11:59 +08:00
|
|
|
- apiGroups:
|
|
|
|
- ''
|
|
|
|
resources:
|
|
|
|
- events
|
|
|
|
verbs:
|
|
|
|
- create
|
|
|
|
- patch
|
|
|
|
- apiGroups:
|
|
|
|
- policy
|
|
|
|
resourceNames:
|
|
|
|
- speaker
|
|
|
|
resources:
|
|
|
|
- podsecuritypolicies
|
|
|
|
verbs:
|
|
|
|
- use
|
2021-05-12 20:22:17 +08:00
|
|
|
{% endif %}
|
2020-06-30 06:11:59 +08:00
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: Role
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: config-watcher
|
|
|
|
namespace: metallb-system
|
|
|
|
rules:
|
|
|
|
- apiGroups:
|
|
|
|
- ''
|
|
|
|
resources:
|
|
|
|
- configmaps
|
|
|
|
verbs:
|
|
|
|
- get
|
|
|
|
- list
|
|
|
|
- watch
|
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: Role
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: pod-lister
|
|
|
|
namespace: metallb-system
|
|
|
|
rules:
|
|
|
|
- apiGroups:
|
|
|
|
- ''
|
|
|
|
resources:
|
|
|
|
- pods
|
|
|
|
verbs:
|
|
|
|
- list
|
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
2021-09-01 18:00:59 +08:00
|
|
|
kind: Role
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: controller
|
|
|
|
namespace: metallb-system
|
|
|
|
rules:
|
|
|
|
- apiGroups:
|
|
|
|
- ''
|
|
|
|
resources:
|
|
|
|
- secrets
|
|
|
|
verbs:
|
|
|
|
- create
|
|
|
|
- apiGroups:
|
|
|
|
- ''
|
|
|
|
resources:
|
|
|
|
- secrets
|
|
|
|
resourceNames:
|
|
|
|
- memberlist
|
|
|
|
verbs:
|
|
|
|
- list
|
|
|
|
- apiGroups:
|
|
|
|
- apps
|
|
|
|
resources:
|
|
|
|
- deployments
|
|
|
|
resourceNames:
|
|
|
|
- controller
|
|
|
|
verbs:
|
|
|
|
- get
|
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
2020-06-30 06:11:59 +08:00
|
|
|
kind: ClusterRoleBinding
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: metallb-system:controller
|
|
|
|
roleRef:
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
kind: ClusterRole
|
|
|
|
name: metallb-system:controller
|
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
|
|
|
name: controller
|
|
|
|
namespace: metallb-system
|
|
|
|
---
|
2021-05-12 20:22:17 +08:00
|
|
|
{% if metallb_speaker_enabled %}
|
2020-06-30 06:11:59 +08:00
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: ClusterRoleBinding
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: metallb-system:speaker
|
|
|
|
roleRef:
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
kind: ClusterRole
|
|
|
|
name: metallb-system:speaker
|
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
|
|
|
name: speaker
|
|
|
|
namespace: metallb-system
|
2021-05-12 20:22:17 +08:00
|
|
|
{% endif %}
|
2020-06-30 06:11:59 +08:00
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: RoleBinding
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: config-watcher
|
|
|
|
namespace: metallb-system
|
|
|
|
roleRef:
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
kind: Role
|
|
|
|
name: config-watcher
|
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
|
|
|
name: controller
|
|
|
|
- kind: ServiceAccount
|
|
|
|
name: speaker
|
|
|
|
---
|
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: RoleBinding
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: pod-lister
|
|
|
|
namespace: metallb-system
|
|
|
|
roleRef:
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
kind: Role
|
|
|
|
name: pod-lister
|
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
|
|
|
name: speaker
|
|
|
|
---
|
2021-09-01 18:00:59 +08:00
|
|
|
apiVersion: rbac.authorization.k8s.io/v1
|
|
|
|
kind: RoleBinding
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
name: controller
|
|
|
|
namespace: metallb-system
|
|
|
|
roleRef:
|
|
|
|
apiGroup: rbac.authorization.k8s.io
|
|
|
|
kind: Role
|
|
|
|
name: controller
|
|
|
|
subjects:
|
|
|
|
- kind: ServiceAccount
|
|
|
|
name: controller
|
|
|
|
---
|
2021-05-12 20:22:17 +08:00
|
|
|
{% if metallb_speaker_enabled %}
|
2020-06-30 06:11:59 +08:00
|
|
|
apiVersion: apps/v1
|
|
|
|
kind: DaemonSet
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
component: speaker
|
|
|
|
name: speaker
|
|
|
|
namespace: metallb-system
|
|
|
|
spec:
|
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
app: metallb
|
|
|
|
component: speaker
|
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
annotations:
|
|
|
|
prometheus.io/port: '{{ metallb_port }}'
|
|
|
|
prometheus.io/scrape: 'true'
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
component: speaker
|
|
|
|
spec:
|
|
|
|
containers:
|
|
|
|
- args:
|
|
|
|
- --port={{ metallb_port }}
|
|
|
|
- --config=config
|
2022-01-14 21:22:28 +08:00
|
|
|
- --log-level={{ metallb_log_level }}
|
2020-06-30 06:11:59 +08:00
|
|
|
env:
|
|
|
|
- name: METALLB_NODE_NAME
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: spec.nodeName
|
|
|
|
- name: METALLB_HOST
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: status.hostIP
|
|
|
|
- name: METALLB_ML_BIND_ADDR
|
|
|
|
valueFrom:
|
|
|
|
fieldRef:
|
|
|
|
fieldPath: status.podIP
|
2021-02-03 17:02:28 +08:00
|
|
|
# needed when another software is also using memberlist / port 7946
|
2021-09-01 18:00:59 +08:00
|
|
|
# when changing this default you also need to update the container ports definition
|
|
|
|
# and the PodSecurityPolicy hostPorts definition
|
2021-02-03 17:02:28 +08:00
|
|
|
#- name: METALLB_ML_BIND_PORT
|
2021-09-01 18:00:59 +08:00
|
|
|
# value: "{{ metallb_memberlist_port }}"
|
2020-06-30 06:11:59 +08:00
|
|
|
- name: METALLB_ML_LABELS
|
|
|
|
value: "app=metallb,component=speaker"
|
|
|
|
- name: METALLB_ML_SECRET_KEY
|
|
|
|
valueFrom:
|
|
|
|
secretKeyRef:
|
|
|
|
name: memberlist
|
|
|
|
key: secretkey
|
2020-09-17 17:45:13 +08:00
|
|
|
image: {{ metallb_speaker_image_repo }}:{{ metallb_version }}
|
2020-06-30 06:11:59 +08:00
|
|
|
name: speaker
|
|
|
|
ports:
|
|
|
|
- containerPort: {{ metallb_port }}
|
|
|
|
name: monitoring
|
2021-09-01 18:00:59 +08:00
|
|
|
- containerPort: {{ metallb_memberlist_port }}
|
|
|
|
name: memberlist-tcp
|
|
|
|
- containerPort: {{ metallb_memberlist_port }}
|
|
|
|
name: memberlist-udp
|
|
|
|
protocol: UDP
|
2022-01-14 21:22:28 +08:00
|
|
|
livenessProbe:
|
|
|
|
httpGet:
|
|
|
|
path: /metrics
|
2022-02-08 01:43:45 +08:00
|
|
|
port: monitoring
|
2022-01-14 21:22:28 +08:00
|
|
|
initialDelaySeconds: 10
|
|
|
|
periodSeconds: 10
|
|
|
|
timeoutSeconds: 1
|
|
|
|
successThreshold: 1
|
|
|
|
failureThreshold: 3
|
|
|
|
readinessProbe:
|
|
|
|
httpGet:
|
|
|
|
path: /metrics
|
2022-02-08 01:43:45 +08:00
|
|
|
port: monitoring
|
2022-01-14 21:22:28 +08:00
|
|
|
initialDelaySeconds: 10
|
|
|
|
periodSeconds: 10
|
|
|
|
timeoutSeconds: 1
|
|
|
|
successThreshold: 1
|
|
|
|
failureThreshold: 3
|
2020-06-30 06:11:59 +08:00
|
|
|
securityContext:
|
|
|
|
allowPrivilegeEscalation: false
|
|
|
|
capabilities:
|
|
|
|
add:
|
|
|
|
- NET_RAW
|
|
|
|
drop:
|
|
|
|
- ALL
|
|
|
|
readOnlyRootFilesystem: true
|
|
|
|
hostNetwork: true
|
2021-03-08 23:57:42 +08:00
|
|
|
{% if metallb_speaker_nodeselector %}
|
|
|
|
nodeSelector:
|
|
|
|
{{ metallb_speaker_nodeselector | to_nice_yaml | indent(width=8) }}
|
|
|
|
{%- endif %}
|
2021-09-02 00:05:00 +08:00
|
|
|
serviceAccountName: speaker
|
|
|
|
terminationGracePeriodSeconds: 2
|
2021-03-08 23:57:42 +08:00
|
|
|
{% if metallb_speaker_tolerations %}
|
2020-06-30 06:11:59 +08:00
|
|
|
tolerations:
|
2021-03-08 23:57:42 +08:00
|
|
|
{{ metallb_speaker_tolerations | to_nice_yaml(indent=2) | indent(width=8) }}
|
|
|
|
{% endif %}
|
2021-05-12 20:22:17 +08:00
|
|
|
{% endif %}
|
2020-06-30 06:11:59 +08:00
|
|
|
---
|
|
|
|
apiVersion: apps/v1
|
|
|
|
kind: Deployment
|
|
|
|
metadata:
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
component: controller
|
|
|
|
name: controller
|
|
|
|
namespace: metallb-system
|
|
|
|
spec:
|
|
|
|
revisionHistoryLimit: 3
|
|
|
|
selector:
|
|
|
|
matchLabels:
|
|
|
|
app: metallb
|
|
|
|
component: controller
|
|
|
|
template:
|
|
|
|
metadata:
|
|
|
|
annotations:
|
|
|
|
prometheus.io/port: '{{ metallb_port }}'
|
|
|
|
prometheus.io/scrape: 'true'
|
|
|
|
labels:
|
|
|
|
app: metallb
|
|
|
|
component: controller
|
|
|
|
spec:
|
2022-01-05 00:20:52 +08:00
|
|
|
priorityClassName: system-cluster-critical
|
2021-03-08 23:57:42 +08:00
|
|
|
{% if metallb_controller_tolerations %}
|
|
|
|
tolerations:
|
|
|
|
{{ metallb_controller_tolerations | to_nice_yaml(indent=2) | indent(width=8) }}
|
|
|
|
{% endif %}
|
2020-06-30 06:11:59 +08:00
|
|
|
containers:
|
|
|
|
- args:
|
|
|
|
- --port={{ metallb_port }}
|
|
|
|
- --config=config
|
2022-01-14 21:22:28 +08:00
|
|
|
- --log-level={{ metallb_log_level }}
|
2021-09-01 18:00:59 +08:00
|
|
|
env:
|
|
|
|
- name: METALLB_ML_SECRET_NAME
|
|
|
|
value: memberlist
|
|
|
|
- name: METALLB_DEPLOYMENT
|
|
|
|
value: controller
|
2020-09-17 17:45:13 +08:00
|
|
|
image: {{ metallb_controller_image_repo }}:{{ metallb_version }}
|
2020-06-30 06:11:59 +08:00
|
|
|
name: controller
|
|
|
|
ports:
|
|
|
|
- containerPort: {{ metallb_port }}
|
|
|
|
name: monitoring
|
|
|
|
securityContext:
|
|
|
|
allowPrivilegeEscalation: false
|
|
|
|
capabilities:
|
|
|
|
drop:
|
|
|
|
- all
|
|
|
|
readOnlyRootFilesystem: true
|
2022-01-14 21:22:28 +08:00
|
|
|
livenessProbe:
|
|
|
|
httpGet:
|
|
|
|
path: /metrics
|
2022-02-08 01:43:45 +08:00
|
|
|
port: monitoring
|
2022-01-14 21:22:28 +08:00
|
|
|
initialDelaySeconds: 10
|
|
|
|
periodSeconds: 10
|
|
|
|
timeoutSeconds: 1
|
|
|
|
successThreshold: 1
|
|
|
|
failureThreshold: 3
|
|
|
|
readinessProbe:
|
|
|
|
httpGet:
|
|
|
|
path: /metrics
|
2022-02-08 01:43:45 +08:00
|
|
|
port: monitoring
|
2022-01-14 21:22:28 +08:00
|
|
|
initialDelaySeconds: 10
|
|
|
|
periodSeconds: 10
|
|
|
|
timeoutSeconds: 1
|
|
|
|
successThreshold: 1
|
|
|
|
failureThreshold: 3
|
2021-09-02 00:05:00 +08:00
|
|
|
{% if metallb_controller_nodeselector %}
|
2020-06-30 06:11:59 +08:00
|
|
|
nodeSelector:
|
2021-09-02 00:05:00 +08:00
|
|
|
{{ metallb_controller_nodeselector | to_nice_yaml | indent(width=8) }}
|
|
|
|
{%- endif %}
|
2020-06-30 06:11:59 +08:00
|
|
|
securityContext:
|
|
|
|
runAsNonRoot: true
|
|
|
|
runAsUser: 65534
|
2021-10-11 23:54:40 +08:00
|
|
|
fsGroup: 65534
|
2020-06-30 06:11:59 +08:00
|
|
|
serviceAccountName: controller
|
|
|
|
terminationGracePeriodSeconds: 0
|