Compare commits

...

14 Commits

Author SHA1 Message Date
Martin Šalata
c22716b470 Bump the chart version 2021-04-05 22:07:35 +02:00
Martin Šalata
ea8755766c Correct the Readme 2021-04-05 22:02:35 +02:00
Martin Šalata
ec9cd60d14 Use github-hosted images in helm 2021-04-05 22:02:22 +02:00
Martin Šalata
6234301c85 Switch dockerhub for Github's docker registry 2021-04-05 22:01:05 +02:00
Martin Šalata
c97fc465e8 Add devel to the docker releases 2021-04-05 21:01:32 +02:00
Martin Šalata
1523ba232b Set cron job to run once a week 2021-04-05 09:06:41 +02:00
Martin Šalata
42be5e1041 Ignore webhook failures to allow entering hibernation 2021-04-04 21:23:00 +02:00
Martin Šalata
5d9930238a Fix apiGroup of certificatesigningrequests 2021-04-04 21:09:13 +02:00
Martin Šalata
ed1b29e8b5 Make CertificateSigningRequest namespaced 2021-04-04 20:36:21 +02:00
Martin Šalata
761a43ed1f Fix certificate generation script arguments 2021-04-04 20:26:44 +02:00
Martin Šalata
4e360ac34f Bump docker and helm versions 2021-04-04 18:47:19 +02:00
Martin Šalata
ee0e41ff32 Add secret type in readme 2021-04-04 18:47:02 +02:00
Martin Šalata
6c4db7d4d1 Standardize secret names 2021-04-04 18:45:24 +02:00
Martin Šalata
c7708d06e5 Add info to readme 2021-04-04 18:24:50 +02:00
11 changed files with 69 additions and 37 deletions

View File

@@ -4,6 +4,7 @@ on:
push: push:
branches: branches:
- main - main
- devel
jobs: jobs:
release: release:
@@ -12,7 +13,7 @@ jobs:
- name: Checkout - name: Checkout
uses: actions/checkout@v1 uses: actions/checkout@v1
with: with:
ref: main ref: ${{ github.ref }}
- name: Configure Git - name: Configure Git
run: | run: |
@@ -22,8 +23,8 @@ jobs:
- name: Build and push docker images (make image) - name: Build and push docker images (make image)
run: make image run: make image
env: env:
DOCKER_USER: '${{ secrets.DOCKER_USER }}' DOCKER_USER: ${GITHUB_ACTOR}
DOCKER_TOKEN: '${{ secrets.DOCKER_TOKEN }}' DOCKER_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Logout from dockerhub (make docker-logout) - name: Logout from dockerhub (make docker-logout)
run: make docker-logout run: make docker-logout

View File

@@ -1,7 +1,8 @@
# Image URL to use all building/pushing image targets; # Image URL to use all building/pushing image targets;
# Use your own docker registry and image name for dev/test by overridding the # Use your own docker registry and image name for dev/test by overridding the
# IMAGE_REPO, IMAGE_NAME and IMAGE_TAG environment variable. # IMAGE_REPO, IMAGE_NAME and IMAGE_TAG environment variable.
IMAGE_REPO ?= marshallmarshall REPOSITORY_BASE ?= ghcr.io
IMAGE_REPO ?= $(REPOSITORY_BASE)/ysoftdevs/imagepullsecret-injector
IMAGE_NAME ?= imagepullsecret-injector IMAGE_NAME ?= imagepullsecret-injector
GENERATOR_IMAGE_NAME ?= webhook-cert-generator GENERATOR_IMAGE_NAME ?= webhook-cert-generator
@@ -81,7 +82,7 @@ build-linux:
image: docker-login build-image push-image image: docker-login build-image push-image
docker-login: docker-login:
@echo ${DOCKER_TOKEN} | docker login -u ${DOCKER_USER} --password-stdin @echo "$(DOCKER_TOKEN)" | docker login -u "$(DOCKER_USER)" --password-stdin "$(REPOSITORY_BASE)"
docker-logout: docker-logout:
@docker logout @docker logout

View File

@@ -2,6 +2,10 @@
The responsibility of this webhook is to patch all newly created/updated service account and make sure they all contained proper imagepullsecret configuration. The responsibility of this webhook is to patch all newly created/updated service account and make sure they all contained proper imagepullsecret configuration.
This repo produces one helm chart available via helm repository https://ysoftdevs.github.io/imagepullsecret-injector. There are also 2 docker images:
- `ghcr.io/ysoftdevs/imagepullsecret-injector/imagepullsecret-injector` - the image containing the webhook itself
- `ghcr.io/ysoftdevs/imagepullsecret-injector/webhook-cert-generator` - helper image responsible for (re)generating the certificates
## Helm description ## Helm description
The helm chart consists of 2 parts: the certificate generator and the webhook configuration itself. The helm chart consists of 2 parts: the certificate generator and the webhook configuration itself.
@@ -21,22 +25,38 @@ The main part is the deployment and the web hook configuration. The flow is as f
Of note is also a fact that the chart runs a lookup to the connected cluster to fetch the CA bundle for the MutatingWebhook. This means `helm template` won't work. Of note is also a fact that the chart runs a lookup to the connected cluster to fetch the CA bundle for the MutatingWebhook. This means `helm template` won't work.
## Running locally ## Running locally
```bash 1. Create the prerequisite resources:
kubectl create ns imagepullsecret-injector ```bash
kubectl create ns imagepullsecret-injector
kubectl create secret -n imagepullsecret-injector \ kubectl create secret -n imagepullsecret-injector \
generic my-cool-secret-source \ generic acr-dockerconfigjson-source \
--from-literal=.dockerconfigjson='<your .dockerconfigjson configuration file>' --type=kubernetes.io/dockerconfigjson \
--from-literal=.dockerconfigjson='<your .dockerconfigjson configuration file>'
```
make build-image 1. Build the images and run the chart
helm upgrade -i imagepullsecret-injector \ ``` bash
--create-namespace -n imagepullsecret-injector \ make build-image
helm/imagepullsecret-injector helm upgrade -i imagepullsecret-injector \
``` -n imagepullsecret-injector \
helm/imagepullsecret-injector
```
Alternatively, you can use the pre-built, publicly available helm chart and docker images:
```bash
helm repo add imagepullsecret-injector https://ysoftdevs.github.io/imagepullsecret-injector
helm repo update
helm upgrade -i imagepullsecret-injector \
-n imagepullsecret-injector \
magepullsecret-injector/imagepullsecret-injector
```
To test whether everything works, you can run 1. To test whether everything works, you can run
```bash ```bash
kubectl create ns yolo kubectl create ns yolo
kubectl get sa -n yolo default -ojsonpath='{.imagePullSecrets}' kubectl get sa -n yolo default -ojsonpath='{.imagePullSecrets}'
``` ```
The get command should display _some_ non-empty result. The `get` command should display _some_ non-empty result.
## Releasing locally
To authenticate to the docker registry to push the images manually, you will need your own Github Personal Access Token. For more information follow this guide https://docs.github.com/en/packages/guides/migrating-to-github-container-registry-for-docker-images#authenticating-with-the-container-registry

View File

@@ -1 +1 @@
v0.0.8 0.0.9

View File

@@ -15,9 +15,9 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes # This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version. # to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/) # Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.0.6 version: 0.0.16
# This is the version number of the application being deployed. This version number should be # This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to # incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using. # follow Semantic Versioning. They should reflect the version the application is using.
appVersion: v0.0.8 appVersion: 0.0.9

View File

@@ -89,6 +89,7 @@ apiVersion: certificates.k8s.io/v1
kind: CertificateSigningRequest kind: CertificateSigningRequest
metadata: metadata:
name: ${csrName} name: ${csrName}
namespace: ${namespace}
spec: spec:
signerName: kubernetes.io/kubelet-serving signerName: kubernetes.io/kubelet-serving
groups: groups:

View File

@@ -5,7 +5,7 @@ metadata:
labels: labels:
{{- include "imagepullsecret-injector.labels" . | nindent 4 }} {{- include "imagepullsecret-injector.labels" . | nindent 4 }}
spec: spec:
schedule: '* * * * *' schedule: '* * * * 0'
jobTemplate: jobTemplate:
metadata: metadata:
name: "{{ .Release.Name }}" name: "{{ .Release.Name }}"
@@ -21,9 +21,12 @@ spec:
image: "{{ .Values.certificateGeneratorImage.registry }}/{{ .Values.certificateGeneratorImage.repository }}:{{ .Values.certificateGeneratorImage.tag | default .Chart.AppVersion }}" image: "{{ .Values.certificateGeneratorImage.registry }}/{{ .Values.certificateGeneratorImage.repository }}:{{ .Values.certificateGeneratorImage.tag | default .Chart.AppVersion }}"
command: ["/entrypoint/entrypoint.sh"] command: ["/entrypoint/entrypoint.sh"]
args: args:
- --service="{{ include "imagepullsecret-injector.serviceName" . }}" - --service
- --namespace="{{ .Release.Namespace }}" - "{{ include "imagepullsecret-injector.serviceName" . }}"
- --secret="{{ include "imagepullsecret-injector.certificateSecretName" . }}" - --namespace
- "{{ .Release.Namespace }}"
- --secret
- "{{ include "imagepullsecret-injector.certificateSecretName" . }}"
volumeMounts: volumeMounts:
- mountPath: "/entrypoint" - mountPath: "/entrypoint"
name: entrypoint name: entrypoint

View File

@@ -14,9 +14,12 @@ spec:
image: "{{ .Values.certificateGeneratorImage.registry }}/{{ .Values.certificateGeneratorImage.repository }}:{{ .Values.certificateGeneratorImage.tag | default .Chart.AppVersion }}" image: "{{ .Values.certificateGeneratorImage.registry }}/{{ .Values.certificateGeneratorImage.repository }}:{{ .Values.certificateGeneratorImage.tag | default .Chart.AppVersion }}"
command: ["/entrypoint/entrypoint.sh"] command: ["/entrypoint/entrypoint.sh"]
args: args:
- --service="{{ include "imagepullsecret-injector.serviceName" . }}" - --service
- --namespace="{{ .Release.Namespace }}" - "{{ include "imagepullsecret-injector.serviceName" . }}"
- --secret="{{ include "imagepullsecret-injector.certificateSecretName" . }}" - --namespace
- "{{ .Release.Namespace }}"
- --secret
- "{{ include "imagepullsecret-injector.certificateSecretName" . }}"
volumeMounts: volumeMounts:
- mountPath: "/entrypoint" - mountPath: "/entrypoint"
name: entrypoint name: entrypoint

View File

@@ -30,15 +30,16 @@ rules:
- list - list
- get - get
- apiGroups: - apiGroups:
- "certificates.k8s.io/v1" - certificates.k8s.io
resources: resources:
- certificatesigningrequests - certificatesigningrequests
verbs: verbs:
- create - create
- list - list
- get - get
- delete
- apiGroups: - apiGroups:
- "certificates.k8s.io/v1" - certificates.k8s.io
resources: resources:
- certificatesigningrequests/approval - certificatesigningrequests/approval
verbs: verbs:

View File

@@ -21,3 +21,5 @@ webhooks:
resources: ["serviceaccounts"] resources: ["serviceaccounts"]
admissionReviewVersions: ["v1", "v1beta1"] admissionReviewVersions: ["v1", "v1beta1"]
sideEffects: None sideEffects: None
# The default "Fail" option prevents Gardener cluster to be hibernated
failurePolicy: Ignore

View File

@@ -1,21 +1,21 @@
image: image:
registry: marshallmarshall registry: ghcr.io/ysoftdevs/imagepullsecret-injector
repository: imagepullsecret-injector repository: imagepullsecret-injector
pullPolicy: Always pullPolicy: Always
# Overrides the image tag whose default is the chart appVersion. # Overrides the image tag whose default is the chart appVersion.
tag: "" tag: ""
certificateGeneratorImage: certificateGeneratorImage:
registry: marshallmarshall registry: ghcr.io/ysoftdevs/imagepullsecret-injector
repository: webhook-cert-generator repository: webhook-cert-generator
tag: "" tag: ""
imagepullsecretInjector: imagepullsecretInjector:
dockerconfigjsonRef: dockerconfigjsonRef:
secretName: my-cool-secret-source secretName: acr-dockerconfigjson-source
secretNamespace: "" secretNamespace: ""
targetSecretName: my-cool-secret targetSecretName: acr-dockerconfigjson
ignoreSecretCreationError: false ignoreSecretCreationError: false
allSaNames: false allSaNames: false
saNames: saNames: