1
0

add operator

This commit is contained in:
2022-08-15 13:43:04 +08:00
parent d2aee92357
commit 9ba33d64d3
15 changed files with 1400 additions and 0 deletions

52
config/deployment.yaml Normal file
View File

@@ -0,0 +1,52 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: controller
namespace: system
spec:
replicas: 2
template:
metadata:
annotations:
prometheus.io/port: "8080"
prometheus.io/scrape: "true"
spec:
securityContext:
runAsNonRoot: true
containers:
- args:
- --metrics-address=:8080
- --enable-leader-election
image: controller:latest
name: manager
env:
- name: POD_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
ports:
- name: monitoring
containerPort: 8080
securityContext:
allowPrivilegeEscalation: false
livenessProbe:
httpGet:
path: /metrics
port: monitoring
initialDelaySeconds: 15
periodSeconds: 20
readinessProbe:
httpGet:
path: /metrics
port: monitoring
initialDelaySeconds: 5
periodSeconds: 10
resources:
limits:
cpu: 100m
memory: 30Mi
requests:
cpu: 100m
memory: 20Mi
serviceAccountName: monitor-manager
terminationGracePeriodSeconds: 10

23
config/kustomization.yaml Normal file
View File

@@ -0,0 +1,23 @@
namespace: kube-system
generatorOptions:
disableNameSuffixHash: true
namePrefix: monitor-
commonLabels:
app: monitor
resources:
- rbac/service_account.yaml
- rbac/role.yaml
- rbac/leader_election_role.yaml
- rbac/role_binding.yaml
- deployment.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: localhost:5000/monitor

View File

@@ -0,0 +1,37 @@
# permissions to do leader election.
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: leader-election-role
rules:
- apiGroups:
- ""
resources:
- configmaps
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- coordination.k8s.io
resources:
- leases
verbs:
- get
- list
- watch
- create
- update
- patch
- delete
- apiGroups:
- ""
resources:
- events
verbs:
- create
- patch

15
config/rbac/role.yaml Normal file
View File

@@ -0,0 +1,15 @@
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
creationTimestamp: null
name: role
rules:
- apiGroups:
- ""
resources:
- services
verbs:
- get
- list
- watch

View File

@@ -0,0 +1,25 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: role
subjects:
- kind: ServiceAccount
name: manager
namespace: system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: leader-election-rolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: leader-election-role
subjects:
- kind: ServiceAccount
name: manager
namespace: system

View File

@@ -0,0 +1,5 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: manager
namespace: system