Skip to content
This repository has been archived by the owner on Oct 29, 2023. It is now read-only.

Commit

Permalink
Merge pull request #3 from oxyno-zeta/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
oxyno-zeta authored Apr 24, 2019
2 parents 20f3fcb + 31538c0 commit a707453
Show file tree
Hide file tree
Showing 31 changed files with 2,127 additions and 369 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ When they can be processed, it will test if rules can be applied with actual tag

Once, this is done, kubernetes-tagger will apply the delta on the target provider.

## How to deploy it ?

For that, we have created a Helm Chart which is located in the "helm-chart" folder in this repository.

Just have a look on the [README](helm-chart/kubernetes-tagger/README.md) in the chart.

## Documentation

- [Configuration](docs/configuration.md)
Expand Down
14 changes: 11 additions & 3 deletions config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
# address: :8085

# Log level
# loglevel: info
loglevel: debug

# Log format
# logformat: json
Expand All @@ -19,13 +19,21 @@ provider: aws
# AWS configuration
aws:
# Region
region: eu-central-1
region: eu-west-3

# Rules to add / delete tags
rules:
# Rule definition add value hardcoded
- tag: tag-hardcoded
value: hardcoded-value
action: delete
- tag: namespace
query: service.namespace
action: add
- tag: name
query: service.name
action: add
- tag: chart
query: service.labels.chart
action: add
# Rule definition add value from query
- tag: tag-query
Expand Down
22 changes: 22 additions & 0 deletions helm-chart/kubernetes-tagger/.helmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
# 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
OWNERS
11 changes: 11 additions & 0 deletions helm-chart/kubernetes-tagger/Chart.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: v1
appVersion: "1.0.0"
description: A Helm chart for Kubernetes Tagger
name: kubernetes-tagger
version: 1.0.0
home: https://github.com/oxyno-zeta/kubernetes-tagger
sources:
- https://github.com/oxyno-zeta/kubernetes-tagger
maintainers:
- name: oxyno-zeta
email: [email protected]
4 changes: 4 additions & 0 deletions helm-chart/kubernetes-tagger/OWNERS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
approvers:
- oxyno-zeta
reviewers:
- oxyno-zeta
94 changes: 94 additions & 0 deletions helm-chart/kubernetes-tagger/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
# kubernetes-tagger

[kubernetes-tagger](https://github.com/oxyno-zeta/kubernetes-tagger) is a Kubernetes watcher that will tag external resources like EBS following rules.

## TL;DR;

```console
$ helm install incubator/kubernetes-tagger
```

## Introduction

This chart bootstraps a kubernetes-tagger deployment on a [Kubernetes](http://kubernetes.io) cluster using the [Helm](https://helm.sh) package manager.

## Installing the Chart

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

```console
$ helm install incubator/kubernetes-tagger --name my-release
```

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

## 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 kubernetes-tagger chart and their default values.

| Parameter | Description | Default |
| -------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------- |
| `rbac.create` | If true, create & use RBAC resources | `false` |
| `rbac.serviceAccountName` | Existing ServiceAccount to use (ignored if rbac.create=true) | `default` |
| `secrets.aws.accessKey` | Will create AWS Access Key in secrets | Empty |
| `secrets.aws.secretKey` | Will create AWS Secret Access Key in secrets | Empty |
| `config` | Kubernetes-tagger configuration (You can see more about this [here](https://github.com/oxyno-zeta/kubernetes-tagger)) | Configuration |
| `replicaCount` | Desired number of pods | `1` |
| `image.name` | Container image name (Including repository name if not `hub.docker.com`). | `oxynozeta/kubernetes-tagger` |
| `image.pullPolicy` | Container pull policy. | `IfNotPresent` |
| `image.tag` | Container image tag. | `1.1.0` |
| `service.annotations` | Annotations to add to service | `{}` |
| `service.clusterIP` | IP address to assign to service | `""` |
| `service.externalIPs` | Service external IP addresses | `[]` |
| `service.loadBalancerIP` | IP address to assign to load balancer (if supported) | `""` |
| `service.loadBalancerSourceRanges` | List of IP CIDRs allowed access to load balancer (if supported) | `[]` |
| `service.servicePort` | Service port to expose | `80` |
| `service.type` | Type of service to create | `ClusterIP` |
| `ingress.enabled` | Enables Ingress | `false` |
| `ingress.annotations` | Ingress annotations | `{}` |
| `ingress.path` | Ingress path | `/` |
| `ingress.hosts` | Ingress accepted hostnames | `[]` |
| `ingress.tls` | Ingress TLS configuration | `[]` |
| `resources` | CPU/Memory resource requests/limits. | `{}` |
| `nodeSelector` | Node labels for pod assignment | `{}` |
| `tolerations` | List of node taints to tolerate (requires Kubernetes >= 1.6) | `[]` |
| `affinity` | List of affinities (requires Kubernetes >=1.6) | `{}` |
| `annotations` | Deployment annotations | `{}` |
| `podAnnotations` | Additional annotations to apply to the pod. | `{}` |
| `podLabels` | Additional labels to apply to the pod. | `{}` |
| `podDisruptionBudget.enabled` | If true, create a pod disruption budget for prometheus pods. The created resource cannot be modified once created - it must be deleted to perform a change | `false` |
| `podDisruptionBudget.minAvailable` | Minimum number / percentage of pods that should remain scheduled | `1` |
| `podDisruptionBudget.maxUnavailable` | Maximum number / percentage of pods that may be made unavailable | `""` |
| `livenessProbe` | Liveness Probe settings | `{ "initialDelaySeconds": 0, "periodSeconds": 30, "timeoutSeconds": 1, "successThreshold": 1, "failureThreshold": 3 }` |
| `readinessProbe` | Readiness Probe settings | `{ "initialDelaySeconds": 0, "periodSeconds": 30, "timeoutSeconds": 1, "successThreshold": 1, "failureThreshold": 3 }` |
| `prometheus.pod.enabled` | If `true`, annotate with Prometheus annotations pods | `false` |
| `prometheus.operator.enabled` | If `true`, creates a Prometheus Operator ServiceMonitor | `false` |
| `prometheus.operator.serviceMonitor.namespace` | Namespace which Prometheus is running in | `monitoring` |
| `prometheus.operator.serviceMonitor.interval` | Interval that Prometheus scrapes metrics | `20s` |
| `prometheus.operator.serviceMonitor.scrapeTimeout` | Scrape timeout for Prometheus scrape metrics | None |
| `prometheus.operator.serviceMonitor.selector` | Default to kube-prometheus install (CoreOS recommended), but should be set according to Prometheus install | `{ prometheus: kube-prometheus }` |

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

```console
$ helm install incubator/kubernetes-tagger --name my-release \
--set=secrets.aws.accessKey="XXXXXXX",secrets.aws.secretKey="XXXXXXX"
```

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

```console
$ helm install incubator/kubernetes-tagger --name my-release -f values.yaml
```

> **Tip**: You can use the default [values.yaml](values.yaml)
21 changes: 21 additions & 0 deletions helm-chart/kubernetes-tagger/templates/NOTES.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ . }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "kubernetes-tagger.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.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 --namespace {{ .Release.Namespace }} svc -w {{ include "kubernetes-tagger.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "kubernetes-tagger.fullname" . }} -o jsonpath='{.status.loadBalancer.ingress[0].ip}')
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "kubernetes-tagger.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
echo "Visit http://127.0.0.1:8085 to use your application"
kubectl port-forward $POD_NAME 8085:80
{{- end }}
32 changes: 32 additions & 0 deletions helm-chart/kubernetes-tagger/templates/_helpers.tpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{{/* vim: set filetype=mustache: */}}
{{/*
Expand the name of the chart.
*/}}
{{- define "kubernetes-tagger.name" -}}
{{- 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 "kubernetes-tagger.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 -}}

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

0 comments on commit a707453

Please sign in to comment.