From 80bf8863ada87191b17d2e372524cc0bde2ff75b Mon Sep 17 00:00:00 2001 From: portdirect Date: Sat, 17 Feb 2018 18:08:45 -0500 Subject: [PATCH] Memcached: Update chart to reflect OpenStack-Helm convention This PS spring cleans the memcached chart to reflect the advances in OSH style. It also updates the image used to the current supported version. Change-Id: Iaeb14e9dd169f009916e64b0c91f2581e64afbca --- memcached/templates/bin/_memcached.sh.tpl | 26 ++++++ memcached/templates/configmap-bin.yaml | 28 ++++++ memcached/templates/deployment.yaml | 31 ++++-- memcached/templates/service.yaml | 2 + memcached/values.yaml | 109 +++++++++++----------- 5 files changed, 136 insertions(+), 60 deletions(-) create mode 100644 memcached/templates/bin/_memcached.sh.tpl create mode 100644 memcached/templates/configmap-bin.yaml diff --git a/memcached/templates/bin/_memcached.sh.tpl b/memcached/templates/bin/_memcached.sh.tpl new file mode 100644 index 0000000000..5d9aeb6b24 --- /dev/null +++ b/memcached/templates/bin/_memcached.sh.tpl @@ -0,0 +1,26 @@ +#!/bin/sh + +{{/* +Copyright 2017 The Openstack-Helm Authors. + +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. +*/}} + +set -ex + +memcached --version +exec memcached -v \ + -p ${MEMCACHED_PORT} \ + -U 0 \ + -c ${MEMCACHED_MAX_CONNECTIONS} \ + -m ${MEMCACHED_MEMORY} diff --git a/memcached/templates/configmap-bin.yaml b/memcached/templates/configmap-bin.yaml new file mode 100644 index 0000000000..2d2b28f6e2 --- /dev/null +++ b/memcached/templates/configmap-bin.yaml @@ -0,0 +1,28 @@ +{{/* +Copyright 2017 The Openstack-Helm Authors. + +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. +*/}} + +{{- if .Values.manifests.configmap_bin }} +{{- $envAll := . }} +{{- $configMapBinName := printf "%s-%s" $envAll.Release.Name "memcached-bin" }} +--- +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ $configMapBinName }} +data: + memcached.sh: | +{{ tuple "bin/_memcached.sh.tpl" . | include "helm-toolkit.utils.template" | indent 4 }} +{{- end }} diff --git a/memcached/templates/deployment.yaml b/memcached/templates/deployment.yaml index 817e170010..cae92406de 100644 --- a/memcached/templates/deployment.yaml +++ b/memcached/templates/deployment.yaml @@ -14,10 +14,13 @@ See the License for the specific language governing permissions and limitations under the License. */}} +{{- if .Values.manifests.deployment }} {{- $envAll := . }} {{- $dependencies := .Values.dependencies.memcached }} {{- $rcControllerName := printf "%s-%s" $envAll.Release.Name "memcached" }} +{{- $configMapBinName := printf "%s-%s" $envAll.Release.Name "memcached-bin" }} + {{ tuple $envAll $dependencies $rcControllerName | include "helm-toolkit.snippets.kubernetes_pod_rbac_serviceaccount" }} --- apiVersion: apps/v1beta1 @@ -44,16 +47,28 @@ spec: image: {{ .Values.images.tags.memcached }} imagePullPolicy: {{ .Values.images.pull_policy }} {{ tuple $envAll $envAll.Values.pod.resources.server | include "helm-toolkit.snippets.kubernetes_resources" | indent 10 }} - command: ["sh", "-xec"] - args: - - | - exec memcached -v \ - -p {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} \ - -U 0 \ - -c {{ .Values.memcached.max_connections }} \ - -m {{ .Values.memcached.memory }}; + env: + - name: MEMCACHED_PORT + value: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" | quote }} + - name: MEMCACHED_MAX_CONNECTIONS + value: {{ .Values.conf.memcached.max_connections | quote }} + - name: MEMCACHED_MEMORY + value: {{ .Values.conf.memcached.memory | quote }} + command: + - /tmp/memcached.sh ports: - containerPort: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} readinessProbe: tcpSocket: port: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} + volumeMounts: + - name: memcached-bin + mountPath: /tmp/memcached.sh + subPath: memcached.sh + readOnly: true + volumes: + - name: memcached-bin + configMap: + name: {{ $configMapBinName | quote }} + defaultMode: 0555 +{{- end }} diff --git a/memcached/templates/service.yaml b/memcached/templates/service.yaml index 9b062c12e3..4d3401c364 100644 --- a/memcached/templates/service.yaml +++ b/memcached/templates/service.yaml @@ -14,6 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */}} +{{- if .Values.manifests.service }} {{- $envAll := . }} --- apiVersion: v1 @@ -26,3 +27,4 @@ spec: - port: {{ tuple "oslo_cache" "internal" "memcache" . | include "helm-toolkit.endpoints.endpoint_port_lookup" }} selector: {{ tuple $envAll "memcached" "server" | include "helm-toolkit.snippets.kubernetes_metadata_labels" | indent 4 }} +{{- end }} diff --git a/memcached/values.yaml b/memcached/values.yaml index 48d5fb78d1..e13f99facc 100644 --- a/memcached/values.yaml +++ b/memcached/values.yaml @@ -17,62 +17,67 @@ # Declare name/value pairs to be passed into your templates. # name: value -images: - tags: - memcached: docker.io/memcached:1.4 - dep_check: quay.io/stackanetes/kubernetes-entrypoint:v0.2.1 - pull_policy: "IfNotPresent" +conf: + memcached: + max_connections: 8192 + #NOTE(pordirect): this should match the value in + # `pod.resources.memcached.memory` + memory: 1024 -pod: - affinity: - anti: - type: - default: preferredDuringSchedulingIgnoredDuringExecution - topologyKey: - default: kubernetes.io/hostname - replicas: - server: 1 - lifecycle: - upgrades: - deployments: - revision_history: 3 - pod_replacement_strategy: RollingUpdate - rolling_update: - max_unavailable: 1 - max_surge: 3 - resources: - enabled: false - server: - limits: - memory: "128Mi" - cpu: "500m" - requests: - memory: "128Mi" - cpu: "500m" +dependencies: + memcached: + jobs: null + +endpoints: + cluster_domain_suffix: cluster.local + oslo_cache: + host_fqdn_override: + default: null + hosts: + default: memcached + namespace: null + port: + memcache: + default: 11211 + +images: + pull_policy: IfNotPresent + tags: + dep_check: 'quay.io/stackanetes/kubernetes-entrypoint:v0.2.1' + memcached: 'docker.io/memcached:1.5.5' labels: node_selector_key: openstack-control-plane node_selector_value: enabled -# typically overriden by environmental -# values, but should include all endpoints -# required by this chart -endpoints: - cluster_domain_suffix: cluster.local - oslo_cache: - namespace: null - hosts: - default: memcached - host_fqdn_override: - default: null - port: - memcache: - default: 11211 +manifests: + configmap_bin: true + deployment: true + service: true -memcached: - memory: 1024 - max_connections: 8192 - -dependencies: - memcached: - jobs: null +pod: + affinity: + anti: + topologyKey: + default: kubernetes.io/hostname + type: + default: preferredDuringSchedulingIgnoredDuringExecution + lifecycle: + upgrades: + deployments: + pod_replacement_strategy: RollingUpdate + revision_history: 3 + rolling_update: + max_surge: 3 + max_unavailable: 1 + replicas: + server: 1 + resources: + enabled: false + memcached: + limits: + cpu: 500m + memory: 1024Mi + requests: + cpu: 500m + memory: 128Mi