Skip to content

Commit

Permalink
feat: rework aws-xray helm chart (#56)
Browse files Browse the repository at this point in the history
Use new style labels and selectors

Use properly indentation

Remove extra documentation

Change pull request template
  • Loading branch information
okgolove authored Sep 24, 2022
1 parent 12e491d commit d14eca5
Show file tree
Hide file tree
Showing 8 changed files with 103 additions and 149 deletions.
1 change: 0 additions & 1 deletion .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#### PR Checklist
[Place an '[x]' (no spaces) in all applicable fields. Please remove unrelated fields.]
- [ ] Chart Version bumped
- [ ] Variables and other changes are documented in the README.md

<!--
Thank you for contributing to okgolove/helm-charts. Before you submit this PR we'd like to
Expand Down
2 changes: 1 addition & 1 deletion charts/aws-xray/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,4 @@ maintainers:
name: aws-xray
sources:
- https://github.com/aws/aws-xray-daemon
version: 3.5.0
version: 4.0.0
65 changes: 1 addition & 64 deletions charts/aws-xray/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,72 +7,9 @@
```console
## Add the okgolove Helm repository
$ helm repo add okgolove https://okgolove.github.io/helm-charts/
$ helm install okgolove/aws-xray
$ helm install aws-xray okgolove/aws-xray
```

## Introduction

This chart bootstraps a [AWS X-Ray](https://aws.amazon.com/xray/) deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Prerequisites

- Kubernetes 1.9+

## Installing the Chart

To install the chart with the release name `my-release`:

```console
$ helm install --name my-release stable/aws-xray
```

The command deploys AWS X-Ray on the Kubernetes cluster in the default configuration. The [configuration](#configuration) section lists the parameters that can be configured during installation.

> **Tip**: List all releases using `helm list`
## Uninstalling the Chart

To uninstall/delete the `my-release` deployment:

```console
$ helm delete my-release
```

The command removes all the Kubernetes components associated with the chart and deletes the release.

## Configuration

The following table lists the configurable parameters of the AWS X-Ray chart and their default values.

| Parameter | Description | Default |
| ------------------------------- | ------------------------------- | ---------------------------------------------------------- |
| `image.repository` | aws-xray image | `public.ecr.aws/xray/aws-xray-daemon` |
| `image.tag` | aws-xray image tag | `3.3.4` |
| `pullPolicy` | Image pull policy | `IfNotPresent` |
| `rbac.create` | Install required rbac clusterrole | `true` |
| `serviceAccount.create` | Enable ServiceAccount creation | `true` |
| `serviceAccount.name` | ServiceAccount for AWS X-Ray pods | `default` |
| `xray.region` | AWS region you deploy AWS X-Ray to | `` |
| `xray.loglevel` | AWS X-Ray daemon log level | `prod` |
| `xray.roleArn` | AWS IAM role to assume | `` |
| `service.port` | Service UDP and TCP port | `2000` |
| `nodeSelector` | Node labels for pod assignment | `{}` |
| `tolerations` | List of node taints to tolerate | `[]` |
| `affinity` | Map of node/pod affinities | `{}` |
| `resources` | CPU/Memory resource requests/limits | `{}` |

Specify each parameter using the `--set key=value[,key=value]` argument to `helm install`. For example,

```console
$ helm install --name my-release \
--set aws-xray.port=8080,serviceAccount.name=aws-xray \
stable/aws-xray
```

Alternatively, a YAML file that specifies the values for the above parameters can be provided while installing the chart. For example,

```console
$ helm install --name my-release -f values.yaml stable/aws-xray
```

> **Tip**: You can use the default [values.yaml](values.yaml)
65 changes: 42 additions & 23 deletions charts/aws-xray/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -1,43 +1,62 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "aws-xray.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "aws-xray.fullname" -}}
{{- if .Values.fullnameOverride -}}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- $name := default .Chart.Name .Values.nameOverride -}}
{{- if contains $name .Release.Name -}}
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
{{- else -}}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}

{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "aws-xray.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
{{- end -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}

{{/*
Create the name of the service account
Common labels
*/}}
{{- define "aws-xray.labels" -}}
helm.sh/chart: {{ include "aws-xray.chart" . }}
{{ include "aws-xray.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{/*
Selector labels
*/}}
{{- define "aws-xray.selectorLabels" -}}
app.kubernetes.io/name: {{ include "aws-xray.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}

{{/*
Create the name of the service account to use
*/}}
{{- define "aws-xray.serviceAccountName" -}}
{{- if .Values.serviceAccount.create -}}
{{ default (include "aws-xray.fullname" .) .Values.serviceAccount.name }}
{{- else -}}
{{ default "default" .Values.serviceAccount.name }}
{{- end -}}
{{- end -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "aws-xray.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}
5 changes: 1 addition & 4 deletions charts/aws-xray/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ kind: ConfigMap
metadata:
name: {{ include "aws-xray.fullname" . }}-config
labels:
app.kubernetes.io/name: {{ include "aws-xray.name" . }}
helm.sh/chart: {{ include "aws-xray.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "aws-xray.labels" . | nindent 4 }}
data:
config.yaml: |-
# Maximum buffer size in MB (minimum 3). Choose 0 to use 1% of host memory.
Expand Down
85 changes: 42 additions & 43 deletions charts/aws-xray/templates/daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,62 @@ kind: DaemonSet
metadata:
name: {{ include "aws-xray.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "aws-xray.name" . }}
helm.sh/chart: {{ include "aws-xray.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "aws-xray.labels" . | nindent 4 }}
spec:
selector:
matchLabels:
app.kubernetes.io/name: {{ include "aws-xray.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "aws-xray.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
app.kubernetes.io/name: {{ include "aws-xray.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "aws-xray.selectorLabels" . | nindent 8 }}
spec:
serviceAccountName: {{ template "aws-xray.serviceAccountName" . }}
{{- if .Values.image.pullSecrets }}
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
- name: {{ .Values.image.pullSecrets }}
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ template "aws-xray.serviceAccountName" . }}
volumes:
- name: config-volume
configMap:
name: "{{ include "aws-xray.fullname" . }}-config"
- name: config-volume
configMap:
name: "{{ include "aws-xray.fullname" . }}-config"
hostNetwork: true
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: xray-daemon
securityContext:
{{- toYaml .Values.securityContext | nindent 10 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: [ "/xray", "-c", "/aws/xray/config.yaml" ]
ports:
- name: xray-ingest
containerPort: 2000
hostPort: 2000
protocol: UDP
- name: xray-tcp
containerPort: 2000
hostPort: 2000
protocol: TCP
volumeMounts:
- name: config-volume
mountPath: /aws/xray
resources:
{{ toYaml .Values.resources | indent 12 }}
{{- with .Values.nodeSelector }}
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
command: ["/xray", "-c", "/aws/xray/config.yaml"]
ports:
- name: xray-ingest
containerPort: 2000
hostPort: 2000
protocol: UDP
- name: xray-tcp
containerPort: 2000
hostPort: 2000
protocol: TCP
volumeMounts:
- name: config-volume
mountPath: /aws/xray
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.affinity }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{ toYaml . | indent 8 }}
{{- end }}
{{- with .Values.tolerations }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{ toYaml . | indent 8 }}
{{- end }}
{{- toYaml . | nindent 8 }}
{{- end }}
8 changes: 2 additions & 6 deletions charts/aws-xray/templates/service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ kind: Service
metadata:
name: {{ include "aws-xray.fullname" . }}
labels:
app.kubernetes.io/name: {{ include "aws-xray.name" . }}
helm.sh/chart: {{ include "aws-xray.chart" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- include "aws-xray.labels" . | nindent 4 }}
spec:
clusterIP: None
ports:
Expand All @@ -17,5 +14,4 @@ spec:
protocol: TCP
name: xray-tcp
selector:
app.kubernetes.io/name: {{ include "aws-xray.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- include "aws-xray.selectorLabels" . | nindent 4 }}
21 changes: 14 additions & 7 deletions charts/aws-xray/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,24 @@
# Declare variables to be passed into your templates.
image:
repository: public.ecr.aws/xray/aws-xray-daemon
tag: 3.3.4
# Overrides the image tag whose default is the chart appVersion.
tag: ""
pullPolicy: IfNotPresent
## Optionally specify an array of imagePullSecrets.
## Secrets must be manually created in the namespace.
## ref: https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
##
# pullSecrets: myRegistrKeySecretName

imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""

serviceAccount:
# Specifies whether a service account should be created
create: true
name:
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""

podAnnotations: {}

podSecurityContext: {}
# fsGroup: 10001
Expand Down

0 comments on commit d14eca5

Please sign in to comment.