From 5e425b9079af38fa01a24c319252f4313888d251 Mon Sep 17 00:00:00 2001 From: Vishal Thapar <5137689+vthapar@users.noreply.github.com> Date: Mon, 20 Apr 2020 19:04:36 +0530 Subject: [PATCH] Add Lighthouse charts This adds the deployment for lighthouse-agent, service account and RBAC. --- submariner-k8s-broker/templates/crd.yaml | 32 ++++++++++++++ submariner-k8s-broker/templates/rbac.yaml | 3 ++ submariner-k8s-broker/values.yaml | 2 + submariner/templates/_helpers.tpl | 11 +++++ submariner/templates/crd.yaml | 32 ++++++++++++++ submariner/templates/lighthouse.yaml | 51 +++++++++++++++++++++++ submariner/templates/rbac.yaml | 27 ++++++++++++ submariner/templates/svc-acct.yaml | 12 ++++++ submariner/values.yaml | 9 ++++ 9 files changed, 179 insertions(+) create mode 100644 submariner/templates/lighthouse.yaml diff --git a/submariner-k8s-broker/templates/crd.yaml b/submariner-k8s-broker/templates/crd.yaml index 192be25..c00408f 100644 --- a/submariner-k8s-broker/templates/crd.yaml +++ b/submariner-k8s-broker/templates/crd.yaml @@ -26,4 +26,36 @@ spec: kind: Endpoint plural: endpoints scope: Namespaced +--- +{{- if .Values.submariner.serviceDiscovery }} +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: multiclusterservices.lighthouse.submariner.io + annotations: + "helm.sh/hook": crd-install +spec: + group: lighthouse.submariner.io + version: v1 + names: + kind: MultiClusterService + plural: multiclusterservices + singular: multiclusterservice + scope: Namespaced + validation: + openAPIV3Schema: + properties: + spec: + properties: + clusterServiceInfo: + properties: + clusterID: + type: "string" + clusterDomain: + type: "string" + serviceIP: + type: "string" + port: + type: "integer" +{{- end -}} {{- end -}} \ No newline at end of file diff --git a/submariner-k8s-broker/templates/rbac.yaml b/submariner-k8s-broker/templates/rbac.yaml index 076dfc4..f494a4d 100644 --- a/submariner-k8s-broker/templates/rbac.yaml +++ b/submariner-k8s-broker/templates/rbac.yaml @@ -12,6 +12,9 @@ rules: - apiGroups: ["submariner.io"] resources: ["clusters", "endpoints"] verbs: ["create", "get", "list", "watch", "patch", "update", "delete"] +- apiGroups: ["lighthouse.submariner.io"] + resources: ["multiclusterservices"] + verbs: ["create", "get", "list", "watch", "patch", "update", "delete"] --- apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding diff --git a/submariner-k8s-broker/values.yaml b/submariner-k8s-broker/values.yaml index edd37f5..2ef184c 100644 --- a/submariner-k8s-broker/values.yaml +++ b/submariner-k8s-broker/values.yaml @@ -7,3 +7,5 @@ serviceAccounts: client: create: true name: "" +submariner: + serviceDiscovery: false diff --git a/submariner/templates/_helpers.tpl b/submariner/templates/_helpers.tpl index 6c860bd..94e04fa 100644 --- a/submariner/templates/_helpers.tpl +++ b/submariner/templates/_helpers.tpl @@ -63,3 +63,14 @@ Create the name of the submariner-globalnet service account to use {{ default "default" .Values.serviceAccounts.globalnet.name }} {{- end -}} {{- end -}} + +{{/* +Create the name of the submariner-lighthouse service account to use +*/}} +{{- define "submariner.lighthouseServiceAccountName" -}} +{{- if .Values.submariner.serviceDiscovery }} + {{ default (printf "%s-lighthouse" (include "submariner.fullname" .)) .Values.serviceAccounts.lighthouse.name }} +{{- else -}} + {{ default "default" .Values.serviceAccounts.lighthouse.name }} +{{- end -}} +{{- end -}} diff --git a/submariner/templates/crd.yaml b/submariner/templates/crd.yaml index 8b4139c..69d3e2d 100644 --- a/submariner/templates/crd.yaml +++ b/submariner/templates/crd.yaml @@ -40,4 +40,36 @@ spec: kind: Gateway plural: gateways scope: Namespaced +--- +{{- if .Values.submariner.serviceDiscovery }} +apiVersion: apiextensions.k8s.io/v1beta1 +kind: CustomResourceDefinition +metadata: + name: multiclusterservices.lighthouse.submariner.io + annotations: + "helm.sh/hook": crd-install +spec: + group: lighthouse.submariner.io + version: v1 + names: + kind: MultiClusterService + plural: multiclusterservices + singular: multiclusterservice + scope: Namespaced + validation: + openAPIV3Schema: + properties: + spec: + properties: + clusterServiceInfo: + properties: + clusterID: + type: "string" + clusterDomain: + type: "string" + serviceIP: + type: "string" + port: + type: "integer" +{{- end }} {{- end -}} diff --git a/submariner/templates/lighthouse.yaml b/submariner/templates/lighthouse.yaml new file mode 100644 index 0000000..d55e4eb --- /dev/null +++ b/submariner/templates/lighthouse.yaml @@ -0,0 +1,51 @@ +{{- if .Values.submariner.serviceDiscovery }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "submariner.fullname" . }}-lighthouse-agent + labels: + heritage: {{ .Release.Service | quote }} + release: {{ .Release.Name | quote }} + chart: {{ template "submariner.chart" . }} + app: {{ template "submariner.fullname" . }}-lighthouse-agent + component: lighthouse +spec: + replicas: 1 + selector: + matchLabels: + app: {{ template "submariner.fullname" . }}-lighthouse-agent + template: + metadata: + labels: + app: {{ template "submariner.fullname" . }}-lighthouse-agent + spec: + serviceAccountName: {{ template "submariner.lighthouseServiceAccountName" . }} + containers: + - command: + - lighthouse-agent.sh + env: + - name: SUBMARINER_NAMESPACE + value: "{{ .Release.Namespace }}" + - name: SUBMARINER_CLUSTERID + value: "{{ .Values.submariner.clusterId }}" + - name: SUBMARINER_DEBUG + value: "{{ .Values.submariner.debug }}" + - name: BROKER_K8S_APISERVER + value: "{{ .Values.broker.server }}" + - name: BROKER_K8S_APISERVERTOKEN + value: "{{ .Values.broker.token }}" + - name: BROKER_K8S_REMOTENAMESPACE + value: "{{ .Values.broker.namespace }}" +{{- if .Values.broker.insecure }} + - name: BROKER_K8S_INSECURE + value: "true" +{{- else }} + - name: BROKER_K8S_CA + value: "{{ .Values.broker.ca }}" +{{- end }} + name: {{ template "submariner.fullname" . }}-lighthouse-agent + image: {{ .Values.lighthouse.image.repository }}:{{ .Values.lighthouse.image.tag }} + imagePullPolicy: {{ .Values.lighthouse.image.pullPolicy }} + restartPolicy: Always + terminationGracePeriodSeconds: 0 +{{- end }} diff --git a/submariner/templates/rbac.yaml b/submariner/templates/rbac.yaml index 202e07a..2a89375 100644 --- a/submariner/templates/rbac.yaml +++ b/submariner/templates/rbac.yaml @@ -109,5 +109,32 @@ subjects: - kind: ServiceAccount name: {{ template "submariner.globalnetServiceAccountName" . }} namespace: {{ .Release.Namespace }} +--- +{{- end -}} +{{- if .Values.submariner.serviceDiscovery }} +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRole +metadata: + name: {{ template "submariner.fullname" . }}:lighthouse +rules: + - apiGroups: [""] + resources: ["services", "namespaces"] + verbs: ["get", "list", "watch", "update"] + - apiGroups: ["lighthouse.submariner.io"] + resources: ["multiclusterservices"] + verbs: ["create", "get", "list", "watch", "update", "delete"] +--- +apiVersion: rbac.authorization.k8s.io/v1 +kind: ClusterRoleBinding +metadata: + name: {{ template "submariner.fullname" . }}:lighthouse +roleRef: + apiGroup: rbac.authorization.k8s.io + kind: ClusterRole + name: {{ template "submariner.fullname" . }}:lighthouse +subjects: + - kind: ServiceAccount + name: {{ template "submariner.lighthouseServiceAccountName" . }} + namespace: {{ .Release.Namespace }} {{- end -}} {{- end -}} diff --git a/submariner/templates/svc-acct.yaml b/submariner/templates/svc-acct.yaml index 4b819cf..cecf8e1 100644 --- a/submariner/templates/svc-acct.yaml +++ b/submariner/templates/svc-acct.yaml @@ -33,3 +33,15 @@ metadata: chart: {{ template "submariner.chart" . }} app: {{ template "submariner.name" . }} {{- end }} +--- +{{- if .Values.serviceAccounts.lighthouse.create }} +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "submariner.lighthouseServiceAccountName" . }} + labels: + heritage: {{ .Release.Service | quote }} + release: {{ .Release.Name | quote }} + chart: {{ template "submariner.chart" . }} + app: {{ template "submariner.name" . }} +{{- end }} diff --git a/submariner/values.yaml b/submariner/values.yaml index a3f39f9..023c050 100644 --- a/submariner/values.yaml +++ b/submariner/values.yaml @@ -8,6 +8,7 @@ submariner: natEnabled: false colorCodes: blue debug: false + serviceDiscovery: false crd: create: true broker: @@ -58,6 +59,11 @@ globalnet: repository: submariner-globalnet tag: local pullPolicy: IfNotPresent +lighthouse: + image: + repository: lighthouse-agent + tag: local + pullPolicy: IfNotPresent serviceAccounts: engine: create: true @@ -68,3 +74,6 @@ serviceAccounts: globalnet: create: false name: "" + lighthouse: + create: false + name: ""