Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for multi network #283

Merged
merged 3 commits into from
Nov 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Dockerfile.controlplane
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ FROM ubuntu:20.04
RUN apt-get update && apt-get install -y curl jq && \
apt-get purge --auto-remove && apt-get clean && rm -rf /var/lib/apt/lists/*
COPY --from=builder /go/src/github.com/AliyunContainerService/terway/terway-controlplane /usr/bin/terway-controlplane
ENTRYPOINT ["/usr/bin/terway-controlplane"]
RUN useradd -U -u 1000 nonroot
USER 1000
ENTRYPOINT ["/usr/bin/terway-controlplane"]
2 changes: 1 addition & 1 deletion charts/terway-controlplane/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ name: terway-controlplane
description: Terway ControlPlane
type: application
version: 0.1.0
appVersion: "1.16.0"
appVersion: "0.1.0"
4 changes: 0 additions & 4 deletions charts/terway-controlplane/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,3 @@ Selector labels
{{- define "terway-controlplane.selectorLabels" -}}
app.kubernetes.io/name: {{ include "terway-controlplane.name" . }}
{{- end }}

{{- define "terway-controlplane.serviceAccountName" -}}
{{- default .Chart.Name }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/terway-controlplane/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
rules:
- apiGroups: [ "" ]
resources:
Expand Down Expand Up @@ -50,4 +50,4 @@ rules:
- patch
- get
resourceNames:
- {{ .Chart.Name }}
- {{ .Release.Name }}
6 changes: 3 additions & 3 deletions charts/terway-controlplane/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
subjects:
- kind: ServiceAccount
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
21 changes: 21 additions & 0 deletions charts/terway-controlplane/templates/configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}
labels:
{{- include "terway-controlplane.labels" . | nindent 4 }}
data:
ctrl-config.yaml: |
leaseLockName: "terway-controller-lock"
leaseLockNamespace: "kube-system"
controllerNamespace: "kube-system"
controllerName: "{{ .Release.Name }}"
healthzBindAddress: "0.0.0.0:8080"
clusterDomain: "cluster.local"
leaderElection: true
webhookPort: 4443
certDir: "/var/run/webhook-cert"
regionID: "{{ .Values.regionID }}"
clusterID: "{{ .Values.clusterID }}"
vpcID: "{{ .Values.vpcID }}"
ipStack: "{{ .Values.ipStack }}"
62 changes: 42 additions & 20 deletions charts/terway-controlplane/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -1,35 +1,32 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
labels:
{{- include "terway-controlplane.labels" . | nindent 4 }}
{{- include "terway-controlplane.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
{{- include "terway-controlplane.selectorLabels" . | nindent 6 }}
{{- include "terway-controlplane.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "terway-controlplane.selectorLabels" . | nindent 8 }}
{{- include "terway-controlplane.selectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ include "terway-controlplane.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
serviceAccountName: {{ .Release.Name }}
containers:
- name: terway-controlplane
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
envFrom:
- secretRef:
name: {{ .Chart.Name }}-credential
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true
runAsUser: 1000
env:
- name: K8S_POD_NAME
valueFrom:
Expand All @@ -40,30 +37,55 @@ spec:
fieldRef:
apiVersion: v1
fieldPath: spec.nodeName
- name: MY_POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
livenessProbe:
periodSeconds: 10
timeoutSeconds: 5
httpGet:
path: /healthz
port: 80
port: 8080
readinessProbe:
initialDelaySeconds: 10
periodSeconds: 10
timeoutSeconds: 5
httpGet:
path: /readyz
port: 80
port: 8080
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- toYaml .Values.resources | nindent 12 }}
volumeMounts:
- name: config-vol
mountPath: /etc/config
readOnly: true
- name: secret-vol
mountPath: /etc/credential
readOnly: true
- name: webhook-vol
mountPath: /var/run/webhook-cert
volumes:
- name: config-vol
configMap:
name: {{ .Release.Name }}
items:
- key: ctrl-config.yaml
path: ctrl-config.yaml
- name: secret-vol
secret:
secretName: {{ .Release.Name }}-credential
- name: webhook-vol
emptyDir: {}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- toYaml . | nindent 8 }}
{{- end }}
4 changes: 2 additions & 2 deletions charts/terway-controlplane/templates/role.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
rules:
- apiGroups: [ "" ]
resources:
Expand All @@ -17,7 +17,7 @@ rules:
- patch
- watch
resourceNames:
- {{ .Chart.Name }}
- {{ .Release.Name }}-webhook-cert
- apiGroups:
- coordination.k8s.io
resources:
Expand Down
6 changes: 3 additions & 3 deletions charts/terway-controlplane/templates/rolebinding.yaml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: Role
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
subjects:
- kind: ServiceAccount
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
namespace: {{ .Release.Namespace }}
10 changes: 10 additions & 0 deletions charts/terway-controlplane/templates/secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-credential
labels:
{{- include "terway-controlplane.labels" . | nindent 4 }}
stringData:
ctrl-secret.yaml: |
accessKey: "{{ .Values.accessKey }}"
accessSecret: "{{ .Values.accessSecret }}"
6 changes: 3 additions & 3 deletions charts/terway-controlplane/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
labels:
{{- include "terway-controlplane.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: 443
targetPort: 4443
protocol: TCP
name: http
name: https
selector:
{{- include "terway-controlplane.selectorLabels" . | nindent 4 }}
2 changes: 1 addition & 1 deletion charts/terway-controlplane/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "terway-controlplane.serviceAccountName" . }}
name: {{ .Release.Name }}
labels:
{{- include "terway-controlplane.labels" . | nindent 4 }}
19 changes: 12 additions & 7 deletions charts/terway-controlplane/templates/webhook.yaml
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
apiVersion: admissionregistration.k8s.io/v1
kind: MutatingWebhookConfiguration
metadata:
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
labels:
{{- include "terway-controlplane.labels" . | nindent 4 }}
webhooks:
- name: {{ .Chart.Name }}.mutating.k8s.io
namespaceSelector:
matchExpressions:
- key: k8s.aliyun.com/pod-eni
operator: NotIn
values: ["false"]
rules:
- apiGroups: [""]
apiVersions: ["v1"]
Expand All @@ -20,17 +25,17 @@ webhooks:
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
path: /mutating
admissionReviewVersions: ["v1", "v1beta1"]
sideEffects: None
timeoutSeconds: 10
failurePolicy: Ignore
timeoutSeconds: {{ .Values.webhookTimeoutSeconds }}
failurePolicy: {{ .Values.webhookFailurePolicy }}
---
apiVersion: admissionregistration.k8s.io/v1
kind: ValidatingWebhookConfiguration
metadata:
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
labels:
{{- include "terway-controlplane.labels" . | nindent 4 }}
webhooks:
Expand All @@ -44,9 +49,9 @@ webhooks:
clientConfig:
service:
namespace: {{ .Release.Namespace }}
name: {{ .Chart.Name }}
name: {{ .Release.Name }}
path: /validate
admissionReviewVersions: ["v1", "v1beta1"]
sideEffects: None
timeoutSeconds: 10
timeoutSeconds: {{ .Values.webhookTimeoutSeconds }}
failurePolicy: Fail
26 changes: 14 additions & 12 deletions charts/terway-controlplane/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,25 +7,13 @@ replicaCount: 2
image:
repository: l1b0k/terway-controlplane
pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion.
tag: "latest"

nameOverride: ""
fullnameOverride: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 2000

securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000

service:
type: ClusterIP
port: 443
Expand All @@ -40,3 +28,17 @@ nodeSelector: {}
tolerations: []

affinity: {}

webhookFailurePolicy: Ignore
webhookTimeoutSeconds: 10

# configmap
regionID: ch-hangzhou
clusterID: ""
vpcID: ""

ipStack: ipv4

# secrets
accessKey: ""
accessSecret: ""
Loading