summaryrefslogtreecommitdiffstats
path: root/kubernetes/msb/components/msb-consul
diff options
context:
space:
mode:
authorSylvain Desbureaux <sylvain.desbureaux@orange.com>2020-11-21 22:50:06 +0100
committerSylvain Desbureaux <sylvain.desbureaux@orange.com>2020-11-30 21:05:41 +0000
commitfd2f8b8d029ea7e83da16d40cd023cebe4b2f75e (patch)
tree75b45c3ea6bb8ee6ce6e5658da37546ca11de78d /kubernetes/msb/components/msb-consul
parentdd99d982adf86279d73d0db7cde0a728e422133d (diff)
[MSB] Uses new tpls for repos / images
This commit makes MSB chart to use the new generator for repositories and images. As new templates doesn't work well with "sub charts", we move also subcharts to components folder. Issue-ID: OOM-2364 Signed-off-by: Sylvain Desbureaux <sylvain.desbureaux@orange.com> Change-Id: I97de4e13d077a6b7139d98dcd855f93645489035
Diffstat (limited to 'kubernetes/msb/components/msb-consul')
-rw-r--r--kubernetes/msb/components/msb-consul/.helmignore21
-rw-r--r--kubernetes/msb/components/msb-consul/Chart.yaml17
-rw-r--r--kubernetes/msb/components/msb-consul/requirements.yaml20
-rwxr-xr-xkubernetes/msb/components/msb-consul/resources/docker-entrypoint.sh100
-rw-r--r--kubernetes/msb/components/msb-consul/templates/NOTES.txt32
-rw-r--r--kubernetes/msb/components/msb-consul/templates/configmap.yaml27
-rw-r--r--kubernetes/msb/components/msb-consul/templates/deployment.yaml97
-rw-r--r--kubernetes/msb/components/msb-consul/templates/ingress.yaml1
-rw-r--r--kubernetes/msb/components/msb-consul/templates/service.yaml41
-rw-r--r--kubernetes/msb/components/msb-consul/values.yaml89
10 files changed, 445 insertions, 0 deletions
diff --git a/kubernetes/msb/components/msb-consul/.helmignore b/kubernetes/msb/components/msb-consul/.helmignore
new file mode 100644
index 0000000000..f0c1319444
--- /dev/null
+++ b/kubernetes/msb/components/msb-consul/.helmignore
@@ -0,0 +1,21 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
diff --git a/kubernetes/msb/components/msb-consul/Chart.yaml b/kubernetes/msb/components/msb-consul/Chart.yaml
new file mode 100644
index 0000000000..fc4f22463b
--- /dev/null
+++ b/kubernetes/msb/components/msb-consul/Chart.yaml
@@ -0,0 +1,17 @@
+# Copyright © 2018 Amdocs, Bell Canada , ZTE
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+apiVersion: v1
+description: ONAP MicroServices Bus Consul
+name: msb-consul
+version: 7.0.0
diff --git a/kubernetes/msb/components/msb-consul/requirements.yaml b/kubernetes/msb/components/msb-consul/requirements.yaml
new file mode 100644
index 0000000000..467a52ab21
--- /dev/null
+++ b/kubernetes/msb/components/msb-consul/requirements.yaml
@@ -0,0 +1,20 @@
+# Copyright © 2018 Amdocs, Bell Canada , ZTE
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+dependencies:
+ - name: common
+ version: ~7.x-0
+ repository: '@local'
+ - name: repositoryGenerator
+ version: ~7.x-0
+ repository: '@local'
diff --git a/kubernetes/msb/components/msb-consul/resources/docker-entrypoint.sh b/kubernetes/msb/components/msb-consul/resources/docker-entrypoint.sh
new file mode 100755
index 0000000000..0cd46167e4
--- /dev/null
+++ b/kubernetes/msb/components/msb-consul/resources/docker-entrypoint.sh
@@ -0,0 +1,100 @@
+#!/usr/bin/dumb-init /bin/sh
+set -e
+set -x
+
+# Note above that we run dumb-init as PID 1 in order to reap zombie processes
+# as well as forward signals to all processes in its session. Normally, sh
+# wouldn't do either of these functions so we'd leak zombies as well as do
+# unclean termination of all our sub-processes.
+# As of docker 1.13, using docker run --init achieves the same outcome.
+
+# You can set CONSUL_BIND_INTERFACE to the name of the interface you'd like to
+# bind to and this will look up the IP and pass the proper -bind= option along
+# to Consul.
+CONSUL_BIND=
+if [ -n "$CONSUL_BIND_INTERFACE" ]; then
+ CONSUL_BIND_ADDRESS=$(ip -o -4 addr list $CONSUL_BIND_INTERFACE | head -n1 | awk '{print $4}' | cut -d/ -f1)
+ if [ -z "$CONSUL_BIND_ADDRESS" ]; then
+ echo "Could not find IP for interface '$CONSUL_BIND_INTERFACE', exiting"
+ exit 1
+ fi
+
+ CONSUL_BIND="-bind=$CONSUL_BIND_ADDRESS"
+ echo "==> Found address '$CONSUL_BIND_ADDRESS' for interface '$CONSUL_BIND_INTERFACE', setting bind option..."
+fi
+
+# You can set CONSUL_CLIENT_INTERFACE to the name of the interface you'd like to
+# bind client intefaces (HTTP, DNS, and RPC) to and this will look up the IP and
+# pass the proper -client= option along to Consul.
+CONSUL_CLIENT=
+if [ -n "$CONSUL_CLIENT_INTERFACE" ]; then
+ CONSUL_CLIENT_ADDRESS=$(ip -o -4 addr list $CONSUL_CLIENT_INTERFACE | head -n1 | awk '{print $4}' | cut -d/ -f1)
+ if [ -z "$CONSUL_CLIENT_ADDRESS" ]; then
+ echo "Could not find IP for interface '$CONSUL_CLIENT_INTERFACE', exiting"
+ exit 1
+ fi
+
+ CONSUL_CLIENT="-client=$CONSUL_CLIENT_ADDRESS"
+ echo "==> Found address '$CONSUL_CLIENT_ADDRESS' for interface '$CONSUL_CLIENT_INTERFACE', setting client option..."
+fi
+
+# CONSUL_DATA_DIR is exposed as a volume for possible persistent storage. The
+# CONSUL_CONFIG_DIR isn't exposed as a volume but you can compose additional
+# config files in there if you use this image as a base, or use CONSUL_LOCAL_CONFIG
+# below.
+CONSUL_DATA_DIR=/consul/data
+CONSUL_CONFIG_DIR=/consul/config
+
+# You can also set the CONSUL_LOCAL_CONFIG environemnt variable to pass some
+# Consul configuration JSON without having to bind any volumes.
+if [ -n "$CONSUL_LOCAL_CONFIG" ]; then
+ echo "$CONSUL_LOCAL_CONFIG" > "$CONSUL_CONFIG_DIR/local.json"
+fi
+
+# If the user is trying to run Consul directly with some arguments, then
+# pass them to Consul.
+if [ "${1:0:1}" = '-' ]; then
+ set -- consul "$@"
+fi
+
+# Look for Consul subcommands.
+if [ "$1" = 'agent' ]; then
+ shift
+ set -- consul agent \
+ -data-dir="$CONSUL_DATA_DIR" \
+ -config-dir="$CONSUL_CONFIG_DIR" \
+ $CONSUL_BIND \
+ $CONSUL_CLIENT \
+ "$@"
+elif [ "$1" = 'version' ]; then
+ # This needs a special case because there's no help output.
+ set -- consul "$@"
+elif consul --help "$1" 2>&1 | grep -q "consul $1"; then
+ # We can't use the return code to check for the existence of a subcommand, so
+ # we have to use grep to look for a pattern in the help output.
+ set -- consul "$@"
+fi
+
+# If we are running Consul, make sure it executes as the proper user.
+if [ "$1" = 'consul' ]; then
+ # If the data or config dirs are bind mounted then chown them.
+ # Note: This checks for root ownership as that's the most common case.
+ if [ "$(stat -c %u /consul/data)" != "$(id -u consul)" ]; then
+ chown consul:consul /consul/data
+ fi
+ if [ "$(stat -c %u /consul/config)" != "$(id -u consul)" ]; then
+ chown consul:consul /consul/config
+ fi
+
+ # If requested, set the capability to bind to privileged ports before
+ # we drop to the non-root user. Note that this doesn't work with all
+ # storage drivers (it won't work with AUFS).
+ if [ ! -z ${CONSUL_ALLOW_PRIVILEGED_PORTS+x} ]; then
+ setcap "cap_net_bind_service=+ep" /bin/consul
+ fi
+
+# Instead of using this we run our pod as a non-root user.
+# set -- su-exec consul:consul "$@"
+fi
+
+exec "$@"
diff --git a/kubernetes/msb/components/msb-consul/templates/NOTES.txt b/kubernetes/msb/components/msb-consul/templates/NOTES.txt
new file mode 100644
index 0000000000..e0cea22074
--- /dev/null
+++ b/kubernetes/msb/components/msb-consul/templates/NOTES.txt
@@ -0,0 +1,32 @@
+# Copyright © 2018 Amdocs, Bell Canada , ZTE
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+1. Get the application URL by running these commands:
+{{- if .Values.ingress.enabled }}
+{{- range .Values.ingress.hosts }}
+ http://{{ . }}
+{{- end }}
+{{- else if contains "NodePort" .Values.service.type }}
+ export NODE_PORT=$(kubectl get --namespace {{ include "common.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "common.fullname" . }})
+ export NODE_IP=$(kubectl get nodes --namespace {{ include "common.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}")
+ echo http://$NODE_IP:$NODE_PORT
+{{- else if contains "LoadBalancer" .Values.service.type }}
+ NOTE: It may take a few minutes for the LoadBalancer IP to be available.
+ You can watch the status of by running 'kubectl get svc -w {{ include "common.fullname" . }}'
+ export SERVICE_IP=$(kubectl get svc --namespace {{ include "common.namespace" . }} {{ include "common.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
+ echo http://$SERVICE_IP:{{ .Values.service.externalPort }}
+{{- else if contains "ClusterIP" .Values.service.type }}
+ export POD_NAME=$(kubectl get pods --namespace {{ include "common.namespace" . }} -l "app={{ template "common.name" . }},release={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
+ echo "Visit http://127.0.0.1:8080 to use your application"
+ kubectl port-forward $POD_NAME 8080:{{ .Values.service.internalPort }}
+{{- end }}
diff --git a/kubernetes/msb/components/msb-consul/templates/configmap.yaml b/kubernetes/msb/components/msb-consul/templates/configmap.yaml
new file mode 100644
index 0000000000..32adcaec5f
--- /dev/null
+++ b/kubernetes/msb/components/msb-consul/templates/configmap.yaml
@@ -0,0 +1,27 @@
+{{/*
+# Copyright © 2020 Samsung Electronics
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/}}
+apiVersion: v1
+kind: ConfigMap
+metadata:
+ name: {{ include "common.fullname" . }}-entrypoint
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ include "common.release" . }}
+ heritage: {{ .Release.Service }}
+data:
+{{ tpl (.Files.Glob "resources/*").AsConfig . | indent 2 }}
diff --git a/kubernetes/msb/components/msb-consul/templates/deployment.yaml b/kubernetes/msb/components/msb-consul/templates/deployment.yaml
new file mode 100644
index 0000000000..97dd1781f2
--- /dev/null
+++ b/kubernetes/msb/components/msb-consul/templates/deployment.yaml
@@ -0,0 +1,97 @@
+{{/*
+# Copyright © 2018 Amdocs, Bell Canada , ZTE
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/}}
+apiVersion: apps/v1
+kind: Deployment
+metadata:
+ name: {{ include "common.fullname" . }}
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ include "common.release" . }}
+ heritage: {{ .Release.Service }}
+spec:
+ selector:
+ matchLabels:
+ app: {{ include "common.name" . }}
+ replicas: {{ .Values.replicaCount }}
+ template:
+ metadata:
+ labels:
+ app: {{ include "common.name" . }}
+ release: {{ include "common.release" . }}
+ annotations:
+ sidecar.istio.io/inject: "{{.Values.istioSidecar}}"
+ spec:
+ serviceAccountName: msb
+ containers:
+ - name: {{ include "common.name" . }}
+ image: {{ include "repositoryGenerator.dockerHubRepository" . }}/{{ .Values.image }}
+ imagePullPolicy: {{ .Values.global.pullPolicy | default .Values.pullPolicy }}
+ securityContext:
+ runAsUser: {{ .Values.securityContext.runAsUser }}
+ runAsGroup: {{ .Values.securityContext.runAsGroup }}
+ command:
+ - docker-entrypoint.sh
+ args:
+ - "agent"
+ - "-dev"
+ - "-client"
+ - "0.0.0.0"
+ ports:
+ - containerPort: {{ .Values.service.internalPort }}
+ # disable liveness probe when breakpoints set in debugger
+ # so K8s doesn't restart unresponsive container
+ {{- if eq .Values.liveness.enabled true }}
+ livenessProbe:
+ tcpSocket:
+ port: {{ .Values.service.internalPort }}
+ initialDelaySeconds: {{ .Values.liveness.initialDelaySeconds }}
+ periodSeconds: {{ .Values.liveness.periodSeconds }}
+ {{ end -}}
+ readinessProbe:
+ tcpSocket:
+ port: {{ .Values.service.internalPort }}
+ initialDelaySeconds: {{ .Values.readiness.initialDelaySeconds }}
+ periodSeconds: {{ .Values.readiness.periodSeconds }}
+ env:
+ volumeMounts:
+ - mountPath: /etc/localtime
+ name: localtime
+ readOnly: true
+ - mountPath: /usr/local/bin/docker-entrypoint.sh
+ name: entrypoint
+ subPath: docker-entrypoint.sh
+ resources:
+{{ include "common.resources" . | indent 12 }}
+ {{- if .Values.nodeSelector }}
+ nodeSelector:
+{{ toYaml .Values.nodeSelector | indent 10 }}
+ {{- end -}}
+ {{- if .Values.affinity }}
+ affinity:
+{{ toYaml .Values.affinity | indent 10 }}
+ {{- end }}
+ volumes:
+ - name: localtime
+ hostPath:
+ path: /etc/localtime
+ - name: entrypoint
+ configMap:
+ name: {{ include "common.fullname" . }}-entrypoint
+ defaultMode: 0777
+ imagePullSecrets:
+ - name: "{{ include "common.namespace" . }}-docker-registry-key"
diff --git a/kubernetes/msb/components/msb-consul/templates/ingress.yaml b/kubernetes/msb/components/msb-consul/templates/ingress.yaml
new file mode 100644
index 0000000000..8f87c68f1e
--- /dev/null
+++ b/kubernetes/msb/components/msb-consul/templates/ingress.yaml
@@ -0,0 +1 @@
+{{ include "common.ingress" . }}
diff --git a/kubernetes/msb/components/msb-consul/templates/service.yaml b/kubernetes/msb/components/msb-consul/templates/service.yaml
new file mode 100644
index 0000000000..af735b6e74
--- /dev/null
+++ b/kubernetes/msb/components/msb-consul/templates/service.yaml
@@ -0,0 +1,41 @@
+{{/*
+# Copyright © 2018 Amdocs, Bell Canada , ZTE
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+*/}}
+apiVersion: v1
+kind: Service
+metadata:
+ name: {{ .Values.service.name }}
+ namespace: {{ include "common.namespace" . }}
+ labels:
+ app: {{ include "common.name" . }}
+ chart: {{ .Chart.Name }}-{{ .Chart.Version | replace "+" "_" }}
+ release: {{ include "common.release" . }}
+ heritage: {{ .Release.Service }}
+ annotations:
+spec:
+ type: {{ .Values.service.type }}
+ ports:
+ {{if eq .Values.service.type "NodePort" -}}
+ - port: {{ .Values.service.externalPort }}
+ nodePort: {{ .Values.global.nodePortPrefix | default .Values.nodePortPrefix }}{{ .Values.service.nodePort }}
+ name: http-{{ .Values.service.name }}
+ {{- else -}}
+ - port: {{ .Values.service.externalPort }}
+ targetPort: {{ .Values.service.internalPort }}
+ name: http-{{ .Values.service.name }}
+ {{- end}}
+ selector:
+ app: {{ include "common.name" . }}
+ release: {{ include "common.release" . }}
diff --git a/kubernetes/msb/components/msb-consul/values.yaml b/kubernetes/msb/components/msb-consul/values.yaml
new file mode 100644
index 0000000000..1c7fa38171
--- /dev/null
+++ b/kubernetes/msb/components/msb-consul/values.yaml
@@ -0,0 +1,89 @@
+# Copyright © 2018 Amdocs, Bell Canada , ZTE
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#################################################################
+# Global configuration defaults.
+#################################################################
+global:
+ nodePortPrefix: 302
+
+#################################################################
+# Application configuration defaults.
+#################################################################
+# application image
+image: library/consul:1.4.3
+pullPolicy: Always
+istioSidecar: true
+
+# application configuration
+config: {}
+
+# default number of instances
+replicaCount: 1
+
+nodeSelector: {}
+
+affinity: {}
+
+# probe configuration parameters
+liveness:
+ initialDelaySeconds: 10
+ periodSeconds: 10
+ # necessary to disable liveness probe when setting breakpoints
+ # in debugger so K8s doesn't restart unresponsive container
+ enabled: true
+
+readiness:
+ initialDelaySeconds: 10
+ periodSeconds: 10
+
+service:
+ type: ClusterIP
+ name: msb-consul
+ externalPort: 8500
+ internalPort: 8500
+ nodePort: 85
+
+ingress:
+ enabled: false
+ service:
+ - baseaddr: "msbconsul"
+ name: "msb-consul"
+ port: 8500
+ config:
+ ssl: "none"
+
+flavor: small
+
+# Configure resource requests and limits
+resources:
+ small:
+ limits:
+ cpu: 20m
+ memory: 100Mi
+ requests:
+ cpu: 10m
+ memory: 50Mi
+ large:
+ limits:
+ cpu: 40m
+ memory: 200Mi
+ requests:
+ cpu: 20m
+ memory: 100Mi
+ unlimited: {}
+
+securityContext:
+ fsGroup: 1000
+ runAsUser: 100
+ runAsGroup: 1000