From f3550f466d640a49bc9dc162dce96069b358ca95 Mon Sep 17 00:00:00 2001 From: Ali Essam Date: Mon, 15 Apr 2019 13:38:03 +0200 Subject: [PATCH] [stable/apm-server] Add support for Service and Deployment (#11661) * [stable/apm-server] Add support for Deployment Signed-off-by: Ali Essam * [stable/apm-server] Update labels & apiVersion Signed-off-by: Ali Essam * [stable/apm-server] Bump version to 1.0.0 Signed-off-by: Ali Essam * feat(probes): add probes to deployment. Set default host as 0.0.0.0 Signed-off-by: Mahdi Dibaiee * bump version for breaking change Signed-off-by: Paul Czarkowski --- stable/apm-server/Chart.yaml | 2 +- stable/apm-server/README.md | 17 +++ stable/apm-server/templates/NOTES.txt | 2 +- stable/apm-server/templates/clusterrole.yaml | 8 +- .../templates/clusterrolebinding.yaml | 8 +- stable/apm-server/templates/daemonset.yaml | 35 ++++-- stable/apm-server/templates/deployment.yaml | 105 ++++++++++++++++++ stable/apm-server/templates/secret.yaml | 8 +- stable/apm-server/templates/service.yaml | 51 +++++++++ .../apm-server/templates/serviceaccount.yaml | 8 +- stable/apm-server/values.yaml | 47 +++++++- 11 files changed, 259 insertions(+), 32 deletions(-) create mode 100644 stable/apm-server/templates/deployment.yaml create mode 100644 stable/apm-server/templates/service.yaml diff --git a/stable/apm-server/Chart.yaml b/stable/apm-server/Chart.yaml index e97b398b358a..db585822a21b 100644 --- a/stable/apm-server/Chart.yaml +++ b/stable/apm-server/Chart.yaml @@ -2,7 +2,7 @@ apiVersion: v1 description: The server receives data from the Elastic APM agents and stores the data into a datastore like Elasticsearch icon: https://www.elastic.co/assets/blt47799dcdcf08438d/logo-elastic-beats-lt.svg name: apm-server -version: 1.0.0 +version: 2.0.0 appVersion: 6.6.2 home: https://www.elastic.co/solutions/apm sources: diff --git a/stable/apm-server/README.md b/stable/apm-server/README.md index c85f29fc3a55..4a5a4bbdbe99 100644 --- a/stable/apm-server/README.md +++ b/stable/apm-server/README.md @@ -43,6 +43,20 @@ The following table lists the configurable parameters of the apm-server chart an | `image.repository` | The image repository to pull from | `docker.elastic.co/apm/apm-server` | | `image.tag` | The image tag to pull | `6.2.4` | | `image.pullPolicy` | Image pull policy | `IfNotPresent` | +| `kind` | Install as Deployment or DaemonSet | `Deployment` | +| `replicaCount` | Number of replicas when kind is Deployment | `1` | +| `updateStrategy` | Allows setting of RollingUpdate strategy | `{}` | +| `service.enabled` | If true, create service pointing to APM Server | `true` | +| `service.type` | type of service | `ClusterIP` | +| `service.port` | Service port | `8200` | +| `service.portName` | Service port name | None | +| `service.clusterIP` | Static clusterIP or None for headless services | None | +| `service.externalIPs` | External IP addresses | None | +| `service.loadBalancerIP` | Load Balancer IP address | None | +| `service.loadBalancerSourceRanges` | Limit load balancer source IPs to list of CIDRs (where available) | `[]` | +| `service.nodePort` | NodePort value if service.type is NodePort | None | +| `service.annotations` | Kubernetes service annotations | None | +| `service.labels` | Kubernetes service labels | None | | `rbac.create` | If true, create & use RBAC resources | `true` | | `rbac.serviceAccount` | existing ServiceAccount to use (ignored if rbac.create=true) | `default` | | `config` | The content of the configuration file consumed by apm-server. See the [apm-server documentation](https://www.elastic.co/guide/en/beats/apm-server/current/apm-server-reference-yml.html) for full details | | @@ -53,6 +67,9 @@ The following table lists the configurable parameters of the apm-server chart an | `resources.limits.cpu` | CPU resource limits | | | `resources.requests.memory` | Memory resource requests | | | `resources.limits.memory` | Memory resource limits | | +| `nodeSelector` | Node labels for pod assignment | `{}` | +| `tolerations` | List of node taints to tolerate | `[]` | +| `affinity` | Node/Pod affinities | None | Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example, diff --git a/stable/apm-server/templates/NOTES.txt b/stable/apm-server/templates/NOTES.txt index c69de39ffd78..7cb7c5307b32 100644 --- a/stable/apm-server/templates/NOTES.txt +++ b/stable/apm-server/templates/NOTES.txt @@ -1,3 +1,3 @@ To verify that apm-server has started, run: - kubectl --namespace={{ .Release.Namespace }} get pods -l "app={{ template "apm-server.name" . }},release={{ .Release.Name }}" + kubectl --namespace={{ .Release.Namespace }} get pods -l "app.kubernetes.io/name={{ include "apm-server.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" diff --git a/stable/apm-server/templates/clusterrole.yaml b/stable/apm-server/templates/clusterrole.yaml index c936aaa539a7..141a8add06a9 100644 --- a/stable/apm-server/templates/clusterrole.yaml +++ b/stable/apm-server/templates/clusterrole.yaml @@ -4,10 +4,10 @@ kind: ClusterRole metadata: name: {{ template "apm-server.fullname" . }} labels: - app: {{ template "apm-server.name" . }} - chart: {{ template "apm-server.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + app.kubernetes.io/name: {{ include "apm-server.name" . }} + helm.sh/chart: {{ include "apm-server.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} rules: - apiGroups: [""] resources: diff --git a/stable/apm-server/templates/clusterrolebinding.yaml b/stable/apm-server/templates/clusterrolebinding.yaml index 4ca97b92ed6b..54bf393aa2ee 100644 --- a/stable/apm-server/templates/clusterrolebinding.yaml +++ b/stable/apm-server/templates/clusterrolebinding.yaml @@ -4,10 +4,10 @@ kind: ClusterRoleBinding metadata: name: {{ template "apm-server.fullname" . }} labels: - app: {{ template "apm-server.name" . }} - chart: {{ template "apm-server.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + app.kubernetes.io/name: {{ include "apm-server.name" . }} + helm.sh/chart: {{ include "apm-server.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} roleRef: apiGroup: rbac.authorization.k8s.io kind: ClusterRole diff --git a/stable/apm-server/templates/daemonset.yaml b/stable/apm-server/templates/daemonset.yaml index 0d22ce4200f2..b055f0563497 100644 --- a/stable/apm-server/templates/daemonset.yaml +++ b/stable/apm-server/templates/daemonset.yaml @@ -1,27 +1,26 @@ +{{- if eq .Values.kind "DaemonSet" }} apiVersion: apps/v1 kind: DaemonSet metadata: name: {{ template "apm-server.fullname" . }} labels: - app: {{ template "apm-server.name" . }} - chart: {{ template "apm-server.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + app.kubernetes.io/name: {{ include "apm-server.name" . }} + helm.sh/chart: {{ include "apm-server.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} spec: selector: matchLabels: - app: {{ template "apm-server.name" . }} - release: {{ .Release.Name }} + app.kubernetes.io/name: {{ include "apm-server.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} minReadySeconds: 10 updateStrategy: - type: RollingUpdate - rollingUpdate: - maxUnavailable: 1 +{{ toYaml .Values.updateStrategy | indent 4 }} template: metadata: labels: - app: {{ template "apm-server.name" . }} - release: {{ .Release.Name }} + app.kubernetes.io/name: {{ include "apm-server.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} {{- range $key, $value := .Values.podLabels }} {{ $key }}: {{ $value }} {{- end }} @@ -50,7 +49,18 @@ spec: value: {{ $value }} {{- end }} ports: - - containerPort: 8200 + - name: http + containerPort: 8200 + livenessProbe: + httpGet: + path: /healthcheck + port: http + initialDelaySeconds: 60 + readinessProbe: + httpGet: + path: /healthcheck + port: http + initialDelaySeconds: 60 securityContext: runAsUser: 0 resources: @@ -90,3 +100,4 @@ spec: affinity: {{ toYaml .Values.affinity | indent 8 }} {{- end }} +{{- end }} diff --git a/stable/apm-server/templates/deployment.yaml b/stable/apm-server/templates/deployment.yaml new file mode 100644 index 000000000000..3a804971cc3c --- /dev/null +++ b/stable/apm-server/templates/deployment.yaml @@ -0,0 +1,105 @@ +{{- if eq .Values.kind "Deployment" }} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ template "apm-server.fullname" . }} + labels: + app.kubernetes.io/name: {{ include "apm-server.name" . }} + helm.sh/chart: {{ include "apm-server.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} +spec: + replicas: {{ .Values.replicaCount }} + selector: + matchLabels: + app.kubernetes.io/name: {{ include "apm-server.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + minReadySeconds: 10 + strategy: +{{ toYaml .Values.updateStrategy | indent 4 }} + template: + metadata: + labels: + app.kubernetes.io/name: {{ include "apm-server.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + {{- range $key, $value := .Values.podLabels }} + {{ $key }}: {{ $value }} + {{- end }} + annotations: + checksum/secret: {{ toYaml .Values.config | sha256sum }} + {{- range $key, $value := .Values.podAnnotations }} + {{ $key }}: {{ $value }} + {{- end }} + spec: + containers: + - name: {{ .Chart.Name }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "-e" +{{- if .Values.plugins }} + - "--plugin" + - {{ .Values.plugins | join "," | quote }} +{{- end }} +{{- if .Values.extraArgs }} +{{ toYaml .Values.extraArgs | indent 8 }} +{{- end }} + env: +{{- range $key, $value := .Values.extraVars }} + - name: {{ $key }} + value: {{ $value }} +{{- end }} + ports: + - name: http + containerPort: 8200 + protocol: TCP + livenessProbe: + httpGet: + path: /healthcheck + port: http + initialDelaySeconds: 60 + readinessProbe: + httpGet: + path: /healthcheck + port: http + initialDelaySeconds: 60 + securityContext: + runAsUser: 0 + resources: +{{ toYaml .Values.resources | indent 10 }} + volumeMounts: + - name: apm-server-config + mountPath: /usr/share/apm-server/apm-server.yml + readOnly: true + subPath: apm-server.yml + - name: data + mountPath: /usr/share/apm-server/data +{{- if .Values.extraVolumeMounts }} +{{ toYaml .Values.extraVolumeMounts | indent 8 }} +{{- end }} + volumes: + - name: apm-server-config + secret: + secretName: {{ template "apm-server.fullname" . }} + - name: data + hostPath: + path: /var/lib/apm-server + type: DirectoryOrCreate +{{- if .Values.extraVolumes }} +{{ toYaml .Values.extraVolumes | indent 6 }} +{{- end }} + terminationGracePeriodSeconds: 60 + serviceAccountName: {{ template "apm-server.serviceAccountName" . }} +{{- if .Values.nodeSelector }} + nodeSelector: +{{ toYaml .Values.nodeSelector | indent 8 }} + {{- end }} + {{- if .Values.tolerations }} + tolerations: +{{ toYaml .Values.tolerations | indent 8 }} + {{- end }} + {{- if .Values.affinity }} + affinity: +{{ toYaml .Values.affinity | indent 8 }} + {{- end }} +{{- end }} diff --git a/stable/apm-server/templates/secret.yaml b/stable/apm-server/templates/secret.yaml index 7fa592177e46..057b62615106 100644 --- a/stable/apm-server/templates/secret.yaml +++ b/stable/apm-server/templates/secret.yaml @@ -3,10 +3,10 @@ kind: Secret metadata: name: {{ template "apm-server.fullname" . }} labels: - app: {{ template "apm-server.name" . }} - chart: {{ template "apm-server.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + app.kubernetes.io/name: {{ include "apm-server.name" . }} + helm.sh/chart: {{ include "apm-server.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} type: Opaque data: apm-server.yml: {{ toYaml .Values.config | indent 4 | b64enc }} diff --git a/stable/apm-server/templates/service.yaml b/stable/apm-server/templates/service.yaml new file mode 100644 index 000000000000..0742f3e2e091 --- /dev/null +++ b/stable/apm-server/templates/service.yaml @@ -0,0 +1,51 @@ +{{- if .Values.service.enabled }} +apiVersion: v1 +kind: Service +metadata: + labels: + app.kubernetes.io/name: {{ include "apm-server.name" . }} + helm.sh/chart: {{ include "apm-server.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- range $key, $value := .Values.service.labels }} + {{ $key }}: {{ $value | quote }} + {{- end }} + name: {{ template "apm-server.fullname" . }} + {{- with .Values.service.annotations }} + annotations: + {{- range $key, $value := . }} + {{ $key }}: {{ $value | quote }} + {{- end }} + {{- end }} +spec: + {{- if .Values.service.loadBalancerSourceRanges }} + loadBalancerSourceRanges: + {{- range $cidr := .Values.service.loadBalancerSourceRanges }} + - {{ $cidr }} + {{- end }} + {{- end }} + type: {{ .Values.service.type }} + {{- if and (eq .Values.service.type "ClusterIP") .Values.service.clusterIP }} + clusterIP: {{ .Values.service.clusterIP }} + {{- end }} + ports: + - port: {{ .Values.service.port }} + targetPort: http + protocol: TCP +{{ if (and (eq .Values.service.type "NodePort") (not (empty .Values.service.nodePort))) }} + nodePort: {{ .Values.service.nodePort }} +{{ end }} +{{- if .Values.service.portName }} + name: {{ .Values.service.portName }} +{{- end }} +{{- if .Values.service.externalIPs }} + externalIPs: +{{ toYaml .Values.service.externalIPs | indent 4 }} +{{- end }} + selector: + app.kubernetes.io/name: {{ include "apm-server.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} +{{- if .Values.service.loadBalancerIP }} + loadBalancerIP: {{ .Values.service.loadBalancerIP }} +{{- end }} +{{- end }} diff --git a/stable/apm-server/templates/serviceaccount.yaml b/stable/apm-server/templates/serviceaccount.yaml index d7decedcc7d2..447525f6fc34 100644 --- a/stable/apm-server/templates/serviceaccount.yaml +++ b/stable/apm-server/templates/serviceaccount.yaml @@ -4,8 +4,8 @@ kind: ServiceAccount metadata: name: {{ template "apm-server.serviceAccountName" . }} labels: - app: {{ template "apm-server.name" . }} - chart: {{ template "apm-server.chart" . }} - release: {{ .Release.Name }} - heritage: {{ .Release.Service }} + app.kubernetes.io/name: {{ include "apm-server.name" . }} + helm.sh/chart: {{ include "apm-server.chart" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end -}} diff --git a/stable/apm-server/values.yaml b/stable/apm-server/values.yaml index d563490281f0..e96028ceffb0 100644 --- a/stable/apm-server/values.yaml +++ b/stable/apm-server/values.yaml @@ -3,10 +3,47 @@ image: tag: 6.6.2 pullPolicy: IfNotPresent +# DaemonSet or Deployment +kind: DaemonSet + +# Number of replicas when kind is Deployment +replicaCount: 1 + +# The update strategy to apply to the Deployment or DaemonSet +updateStrategy: {} + # rollingUpdate: + # maxUnavailable: 1 + # type: RollingUpdate + +service: + enabled: false + type: ClusterIP + port: 8200 + # portName: apm-server-svc + # clusterIP: None + ## External IP addresses of service + ## Default: nil + # externalIPs: + # - 192.168.0.1 + # + ## LoadBalancer IP if service.type is LoadBalancer + ## Default: nil + # loadBalancerIP: 10.2.2.2 + ## Limit load balancer source ips to list of CIDRs (where available) + # loadBalancerSourceRanges: [] + + annotations: {} + # Annotation example: setup ssl with aws cert when service.type is LoadBalancer + # service.beta.kubernetes.io/aws-load-balancer-ssl-cert: arn:aws:acm:us-east-1:EXAMPLE_CERT + labels: {} + ## Label example: show service URL in `kubectl cluster-info` + # kubernetes.io/cluster-service: "true" + + config: - apm-server: {} + apm-server: ### Defines the host and port the server is listening on - # host: "localhost:8200" + host: "0.0.0.0:8200" ## Maximum permitted size in bytes of an unzipped request accepted by the server to be processed. # max_unzipped_size: 52428800 @@ -54,11 +91,13 @@ config: # When a key contains a period, use this format for setting values on the command line: # --set config."output\.file".enabled=false output.file: + # enabled: false path: "/usr/share/apm-server/data" filename: apm-server rotate_every_kb: 10000 number_of_files: 5 + ## Set output.file.enabled to false to enable elasticsearch # output.elasticsearch: # hosts: ["elasticsearch:9200"] # protocol: "https" @@ -110,6 +149,10 @@ resources: {} ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ nodeSelector: {} +# Tolerations for pod assignment +# Ref: https://kubernetes.io/docs/concepts/configuration/taint-and-toleration/ +tolerations: [] + ## Affinity configuration for pod assignment ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ affinity: {}