Skip to content

Commit

Permalink
[stable/apm-server] Add support for Service and Deployment (helm#11661)
Browse files Browse the repository at this point in the history
* [stable/apm-server] Add support for Deployment

Signed-off-by: Ali Essam <[email protected]>

* [stable/apm-server] Update labels & apiVersion

Signed-off-by: Ali Essam <[email protected]>

* [stable/apm-server] Bump version to 1.0.0

Signed-off-by: Ali Essam <[email protected]>

* feat(probes): add probes to deployment. Set default host as 0.0.0.0

Signed-off-by: Mahdi Dibaiee <[email protected]>

* bump version for breaking change

Signed-off-by: Paul Czarkowski <[email protected]>
  • Loading branch information
ali-essam authored and hajnej committed Apr 24, 2019
1 parent 623d3bc commit cf82744
Show file tree
Hide file tree
Showing 11 changed files with 259 additions and 32 deletions.
2 changes: 1 addition & 1 deletion stable/apm-server/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
17 changes: 17 additions & 0 deletions stable/apm-server/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 | |
Expand All @@ -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,

Expand Down
2 changes: 1 addition & 1 deletion stable/apm-server/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -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 }}"
8 changes: 4 additions & 4 deletions stable/apm-server/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions stable/apm-server/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 23 additions & 12 deletions stable/apm-server/templates/daemonset.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -90,3 +100,4 @@ spec:
affinity:
{{ toYaml .Values.affinity | indent 8 }}
{{- end }}
{{- end }}
105 changes: 105 additions & 0 deletions stable/apm-server/templates/deployment.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 4 additions & 4 deletions stable/apm-server/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
51 changes: 51 additions & 0 deletions stable/apm-server/templates/service.yaml
Original file line number Diff line number Diff line change
@@ -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 }}
8 changes: 4 additions & 4 deletions stable/apm-server/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 -}}
47 changes: 45 additions & 2 deletions stable/apm-server/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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: {}
Expand Down

0 comments on commit cf82744

Please sign in to comment.