Skip to content

Commit 9c9cb94

Browse files
authored
Merge branch 'SparebankenVest:master' into custom_resync_periods
2 parents 4e9ede9 + 44777ae commit 9c9cb94

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+2505
-718
lines changed

.github/dependabot.yml

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
version: 2
2+
updates:
3+
- package-ecosystem: "gomod"
4+
directory: "/"
5+
schedule:
6+
interval: "daily"
7+
open-pull-requests-limit: 10
8+
- package-ecosystem: "docker"
9+
directory: "/"
10+
schedule:
11+
interval: "daily"

.github/workflows/controller-build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Setup Golang
2727
uses: actions/setup-go@v1
2828
with:
29-
go-version: '1.13.4'
29+
go-version: '1.18.1'
3030

3131
- name: Build
3232
uses: ./.github/actions/build

.github/workflows/pull-request.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ jobs:
2121
- name: Setup Golang
2222
uses: actions/setup-go@v1
2323
with:
24-
go-version: '1.13.4'
24+
go-version: '1.18.1'
2525

2626
- name: Test
2727
run: make test
2828

2929
- name: Build docker images
30-
run: make build
30+
run: make build

.github/workflows/vaultenv-build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Setup Golang
2727
uses: actions/setup-go@v1
2828
with:
29-
go-version: '1.13.4'
29+
go-version: '1.18.1'
3030

3131
- name: Build
3232
uses: ./.github/actions/build

.github/workflows/webhook-build.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ jobs:
2626
- name: Setup Golang
2727
uses: actions/setup-go@v1
2828
with:
29-
go-version: '1.13.4'
29+
go-version: '1.18.1'
3030

3131
- name: Build
3232
uses: ./.github/actions/build

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
bin
22
debug.test
33
.vscode
4+
.idea
45
/vendor/
56
/tmp/
67
/.tools/
78
*.tmp
89
test.yaml
9-
coverage.txt
10+
coverage.txt

CHANGELOG-1.3.md

+96
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,96 @@
1+
---
2+
title: "Changelog for Version 1.3"
3+
description: "All changes in version 1.3"
4+
---
5+
6+
# Changelog for Version 1.3
7+
8+
## Version 1.3.1
9+
10+
The most notable changes in this release are:
11+
12+
* Fallback to the Pod generated name when creating a secret for an unnamed pod #322
13+
* Use a more refined regex to match valid injectable secret names #320 #281
14+
* Fixes correct RBAC Role vs ClusterRole when `watchAllNamespaces` is `false` SparebankenVest/public-helm-charts#62
15+
* Upgrade k8s client v0.23.5
16+
* Upgrade go 1.18
17+
* Upgrade alpine base image 3.15.6
18+
19+
### Controller
20+
21+
#### Features
22+
23+
* Upgrade k8s client v0.23.5
24+
* Upgrade go 1.18
25+
* Upgrade alpine base image 3.15.6
26+
27+
#### Bug Fixes
28+
29+
* Fallback to the Pod generated name when creating a secret for an unnamed pod #322
30+
* Use a more refined regex to match valid injectable secret names #320 #281
31+
32+
### Helm Charts
33+
34+
* Add priorityClassName spec to akv2k8s controller deployment SparebankenVest/public-helm-charts#60
35+
* Fixes correct RBAC Role vs ClusterRole when `watchAllNamespaces` is `false` SparebankenVest/public-helm-charts#62
36+
* Remove duplicate MTLS_PORT environment variable SparebankenVest/public-helm-charts#70
37+
* Upgrade PodDistributionBudget api version to v1 SparebankenVest/public-helm-charts#71
38+
* Update generated CRD
39+
40+
### Chart and Image versions
41+
42+
| Type | Component | Version |
43+
| ------------ | -------------------------------------------------------------------------------------------------- | ------- |
44+
| Helm Chart | [akv2k8s](https://github.com/SparebankenVest/public-helm-charts/tree/akv2k8s-2.2.0/stable/akv2k8s) | 2.2.0 |
45+
| Docker Image | spvest/azure-keyvault-controller | 1.3.1 |
46+
| Docker Image | spvest/azure-keyvault-webhook | 1.3.1 |
47+
| Docker Image | spvest/azure-keyvault-env | 1.3.1 |
48+
49+
## Version 1.3.0
50+
51+
The most notable changes in this release are:
52+
53+
* Ability to run controller in specific namespace only
54+
* Ability to allow akvs objects with different labels to be handled by controllers with different authorization policies
55+
* Generate CRD's from code with controller-gen
56+
57+
58+
### Controller
59+
60+
#### Features
61+
62+
* #82 - Allow controller to run in specific namespace only
63+
* #159 - Generate crd with controller gen
64+
* #174 - Export certificates stored as Base64 PFX in Azure Key Vault secret object as Kubernetes TLS secret
65+
* #178 - Allow akvs objects with different labels to be handled by controllers with different authorization policies
66+
* #202 - Upgrade dependencies k8s to v0.21.2
67+
* Upgrade to Go 1.16.5
68+
* Upgrade alpine base image to 3.14.0
69+
70+
#### Bug Fixes
71+
72+
* #209 - Fix using an EC header/footer for ECDSA keys
73+
74+
75+
### Docs
76+
77+
* Docs for version `1.3` is default - added version `1.2` to version dropdown
78+
79+
### Helm Charts
80+
81+
* Add generated crd from SparebankenVest/azure-key-vault-to-kubernetes#159
82+
* Ignore files in .helmignore
83+
* Add support for watchAllNamespaces
84+
* SparebankenVest/public-helm-charts#45 - Upgrade cert-manager CRD's to api version v1
85+
* Remove unused RUNNING_INSIDE_AZURE_AKS env
86+
* SparebankenVest/public-helm-charts#57 - Add optional pod annotations to the controller
87+
* SparebankenVest/public-helm-charts#59 - Add optional pod security context
88+
89+
### Chart and Image versions
90+
91+
| Type | Component | Version |
92+
| ------------ | -------------------------------------------------------------------------------------------------- | ------- |
93+
| Helm Chart | [akv2k8s](https://github.com/SparebankenVest/public-helm-charts/tree/akv2k8s-2.1.0/stable/akv2k8s) | 2.1.0 |
94+
| Docker Image | spvest/azure-keyvault-controller | 1.3.0 |
95+
| Docker Image | spvest/azure-keyvault-webhook | 1.3.0 |
96+
| Docker Image | spvest/azure-keyvault-env | 1.3.0 |

Dockerfile

+14-7
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,25 @@
11
ARG BASEIMAGE=gcr.io/distroless/static:nonroot
2-
ARG BASE_ALPINE=alpine:3.13.2
3-
ARG GO_VERSION=1.15.3
2+
ARG BASE_ALPINE=alpine:3.15.4
3+
ARG GO_VERSION=1.18.1
44

55
# -------
66
# Builder
77
# -------
8-
FROM golang:${GO_VERSION} AS builder
8+
FROM golang:${GO_VERSION} AS base_builder
9+
ARG PACKAGE
10+
11+
WORKDIR /go/src/${PACKAGE}
12+
ADD go.mod go.sum /go/src/${PACKAGE}
13+
RUN go mod download
14+
15+
FROM base_builder AS builder
916
ARG PACKAGE
1017
ARG VCS_REF=noref
1118
ARG BUILD_SUB_TARGET
1219

1320
WORKDIR /go/src/${PACKAGE}
21+
1422
ADD . .
15-
RUN go mod download
1623
RUN GIT_TAG=${VCS_REF} make build${BUILD_SUB_TARGET}
1724

1825
# ------------
@@ -28,7 +35,7 @@ LABEL org.label-schema.vcs-ref=$VCS_REF
2835
LABEL org.label-schema.vcs-url=$VCS_URL
2936
LABEL org.label-schema.url=$VCS_URL
3037
LABEL org.label-schema.description="A Kubernetes Mutating Admission Webhook that adds an init container to a pod that will inject environment variables from Azure Key Vault"
31-
LABEL org.label-schema.vendor="Sparebanken Vest"
38+
LABEL org.label-schema.vendor="Sparebanken Vest"
3239
LABEL org.label-schema.author="Jon Arild Tørresdal"
3340

3441
COPY --from=builder /go/src/github.com/SparebankenVest/azure-key-vault-to-kubernetes/bin/azure-key-vault-to-kubernetes/azure-keyvault-secrets-webhook /usr/local/bin/
@@ -48,7 +55,7 @@ LABEL org.label-schema.vcs-ref=$VCS_REF
4855
LABEL org.label-schema.vcs-url=$VCS_URL
4956
LABEL org.label-schema.url=$VCS_URL
5057
LABEL org.label-schema.description="A Kubernetes Mutating Admission Webhook that adds an init container to a pod that will inject environment variables from Azure Key Vault"
51-
LABEL org.label-schema.vendor="Sparebanken Vest"
58+
LABEL org.label-schema.vendor="Sparebanken Vest"
5259
LABEL org.label-schema.author="Jon Arild Tørresdal"
5360

5461
COPY --from=builder /go/src/github.com/SparebankenVest/azure-key-vault-to-kubernetes/bin/azure-key-vault-to-kubernetes/azure-keyvault-controller /usr/local/bin/
@@ -68,7 +75,7 @@ LABEL org.label-schema.vcs-ref=$VCS_REF
6875
LABEL org.label-schema.vcs-url=$VCS_URL
6976
LABEL org.label-schema.url=$VCS_URL
7077
LABEL org.label-schema.description="A Kubernetes Mutating Admission Webhook that adds an init container to a pod that will inject environment variables from Azure Key Vault"
71-
LABEL org.label-schema.vendor="Sparebanken Vest"
78+
LABEL org.label-schema.vendor="Sparebanken Vest"
7279
LABEL org.label-schema.author="Jon Arild Tørresdal"
7380

7481
COPY --from=builder /go/src/github.com/SparebankenVest/azure-key-vault-to-kubernetes/bin/azure-key-vault-to-kubernetes/azure-keyvault-env /usr/local/bin/

Makefile

+3-3
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,8 @@ check-mod: mod
7777

7878
.PHONY: lint
7979
lint: $(TOOLS_DIR)/golangci-lint $(TOOLS_DIR)/misspell
80-
$(TOOLS_DIR)/golangci-lint run --timeout=5m
81-
$(TOOLS_DIR)/misspell -w $(ALL_DOCS) && \
80+
$(TOOLS_DIR)/golangci-lint run --timeout=5m && \
81+
find . -type f \( -iname \*.go -o -iname \*.md \) | xargs $(TOOLS_DIR)/misspell -w && \
8282
go mod tidy
8383

8484
.PHONY: print-v-webhook
@@ -139,7 +139,7 @@ codegen:
139139
.PHONY: crdgen
140140
crdgen: $(TOOLS_DIR)/controller-gen
141141
$(TOOLS_DIR)/controller-gen \
142-
crd:crdVersions=v1,preserveUnknownFields=false,trivialVersions=true \
142+
crd:crdVersions=v1 \
143143
paths=./pkg/k8s/apis/azurekeyvault/v1alpha1/... \
144144
paths=./pkg/k8s/apis/azurekeyvault/v1/... \
145145
paths=./pkg/k8s/apis/azurekeyvault/v2alpha1/... \

README.md

+7-7
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
<p align="center"><i>Documentation available at <a href="https://akv2k8s.io">https://akv2k8s.io</a>. Join our <a href="https://join.slack.com/t/akv2k8s/shared_invite/zt-lfx2qdky-SGjwN8qTfca6bdeIyk46lg">Slack Workspace</a> to ask questions to the akv2k8s community.</i></p>
3434

35-
<p align="center"><i>Please spare one minute to take our survey: <a href="https://www.surveymonkey.com/r/HMFZVYR">https://www.surveymonkey.com/r/HMFZVYR</a>. Why? We have no ide how many are using Akv2k8s, except through user interaction here on GitHub. More importantly - what can we do to make Akv2k8s even better?</i></p>
35+
<p align="center"><i>Please spare one minute to take our survey: <a href="https://www.surveymonkey.com/r/HMFZVYR">https://www.surveymonkey.com/r/HMFZVYR</a>. Why? We have no idea how many are using Akv2k8s, except through user interaction here on GitHub. More importantly - what can we do to make Akv2k8s even better?</i></p>
3636

3737
## Overview
3838

@@ -41,13 +41,13 @@ Azure Key Vault to Kubernetes (akv2k8s) will make Azure Key Vault objects availa
4141
* As native Kubernetes `Secret`s
4242
* As environment variables directly injected into your Container application
4343

44-
The **Azure Key Vault Controller** (Controller for short) is responsible for synchronizing Secrets, Certificates and Keys from Azure Key Vault to native `Secret`'s in Kubernetes.
44+
The **Azure Key Vault Controller** (Controller for short) is responsible for synchronizing Secrets, Certificates and Keys from Azure Key Vault to native `Secret`s in Kubernetes.
4545

46-
The **Azure Key Vault Env Injector** (Env Injector for short) is responsible for transparently injecting Azure Key Vault secrets as environment variables into Container applications, without touching disk or expose the actual secret to Kubernetes.
46+
The **Azure Key Vault Env Injector** (Env Injector for short) is responsible for transparently injecting Azure Key Vault secrets as environment variables into Container applications, without touching disk or exposing the actual secret to Kubernetes.
4747

4848
## Goals
4949

50-
Goals for this project was:
50+
The goals for this project were:
5151

5252
1. Avoid a direct program dependency on Azure Key Vault for getting secrets, and adhere to the 12 Factor App principle for configuration (https://12factor.net/config)
5353
2. Make it simple, secure and low risk to transfer Azure Key Vault secrets into Kubernetes as native Kubernetes secrets
@@ -57,15 +57,15 @@ All of these goals are met.
5757

5858
## Installation
5959

60-
For installation instructions, see documentation at https://akv2k8s.io/installation/
60+
For installation instructions, see documentation at https://akv2k8s.io/installation/.
6161

6262
## Credits
6363

6464
Credit goes to Banzai Cloud for coming up with the [original idea](https://banzaicloud.com/blog/inject-secrets-into-pods-vault/) of environment injection for their [bank-vaults](https://github.com/banzaicloud/bank-vaults) solution, which they use to inject Hashicorp Vault secrets into Pods.
6565

6666
## Contributing
6767

68-
Development of Azure Key Vault for Kubernetes happens in the open on GitHub, and encourage users to:
68+
Development of Azure Key Vault for Kubernetes happens in the open on GitHub, and we encourage users to:
6969

7070
* Send a pull request with
7171
* any security issues found and fixed
@@ -85,5 +85,5 @@ Azure Key Vault to Kubernetes is licensed under Apache License 2.0.
8585

8686
### Contribute to the Documentation
8787

88-
The documentation is located in a seperate repository at https://github.com/SparebankenVest/akv2k8s-website. We're using Gatsby + MDX (Markdown + JSX) to generate static docs for https://akv2k8s.io.
88+
The documentation is located in a separate repository at https://github.com/SparebankenVest/akv2k8s-website. We're using Gatsby + MDX (Markdown + JSX) to generate static docs for https://akv2k8s.io.
8989

cmd/azure-keyvault-controller/controller/azureeKeyVaultSecret_test.go

-1
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ func TestNullLookup(t *testing.T) {
4040
}
4141

4242
const (
43-
fakeSecret = "some secret"
4443
fakeJsonSecret = `{
4544
"someKey": "someValue",
4645
"someOtherKey": "someOtherValue"

cmd/azure-keyvault-controller/controller/configmap.go

+1-16
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,6 @@ import (
3737
"k8s.io/client-go/tools/cache"
3838
)
3939

40-
func convertToConfigMap(obj interface{}) (*corev1.ConfigMap, error) {
41-
cm, ok := obj.(*corev1.ConfigMap)
42-
if !ok {
43-
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
44-
if !ok {
45-
return nil, fmt.Errorf("couldn't get object from tombstone %#v", obj)
46-
}
47-
cm, ok = tombstone.Obj.(*corev1.ConfigMap)
48-
if !ok {
49-
return nil, fmt.Errorf("tombstone contained object that is not a ConfigMap %#v", obj)
50-
}
51-
}
52-
return cm, nil
53-
}
54-
5540
func (c *Controller) getConfigMapByKey(key string) (*corev1.ConfigMap, error) {
5641
namespace, name, err := cache.SplitMetaNamespaceKey(key)
5742
if err != nil {
@@ -290,7 +275,7 @@ func determineConfigMapName(azureKeyVaultSecret *akv.AzureKeyVaultSecret) string
290275
func getMD5HashOfStringValues(values map[string]string) string {
291276
var mergedValues bytes.Buffer
292277

293-
// sort keys to make sure hash is consistant
278+
// sort keys to make sure hash is consistent
294279
keys := sortStringValueKeys(values)
295280

296281
for _, k := range keys {

cmd/azure-keyvault-controller/controller/secret.go

+1-16
Original file line numberDiff line numberDiff line change
@@ -37,21 +37,6 @@ import (
3737
"k8s.io/client-go/tools/cache"
3838
)
3939

40-
func convertToSecret(obj interface{}) (*corev1.Secret, error) {
41-
secret, ok := obj.(*corev1.Secret)
42-
if !ok {
43-
tombstone, ok := obj.(cache.DeletedFinalStateUnknown)
44-
if !ok {
45-
return nil, fmt.Errorf("couldn't get object from tombstone %#v", obj)
46-
}
47-
secret, ok = tombstone.Obj.(*corev1.Secret)
48-
if !ok {
49-
return nil, fmt.Errorf("tombstone contained object that is not a Secret %#v", obj)
50-
}
51-
}
52-
return secret, nil
53-
}
54-
5540
func (c *Controller) getSecretByKey(key string) (*corev1.Secret, error) {
5641
namespace, name, err := cache.SplitMetaNamespaceKey(key)
5742
if err != nil {
@@ -327,7 +312,7 @@ func determineSecretType(azureKeyVaultSecret *akv.AzureKeyVaultSecret) corev1.Se
327312
func getMD5HashOfByteValues(values map[string][]byte) string {
328313
var mergedValues bytes.Buffer
329314

330-
// sort keys to make sure hash is consistant
315+
// sort keys to make sure hash is consistent
331316
keys := sortByteValueKeys(values)
332317

333318
for _, k := range keys {

cmd/azure-keyvault-controller/controller/secret_handler.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ func (h *azureKeyHandler) HandleConfigMap() (map[string]string, error) {
265265
return values, nil
266266
}
267267

268-
// Handle getting and formating Azure Key Vault Secret containing mulitple values from Azure Key Vault to Kubernetes
268+
// Handle getting and formating Azure Key Vault Secret containing multiple values from Azure Key Vault to Kubernetes
269269
func (h *azureMultiValueSecretHandler) HandleSecret() (map[string][]byte, error) {
270270
values := make(map[string][]byte)
271271

@@ -300,7 +300,7 @@ func (h *azureMultiValueSecretHandler) HandleSecret() (map[string][]byte, error)
300300
return values, nil
301301
}
302302

303-
// Handle getting and formating Azure Key Vault Secret containing mulitple values from Azure Key Vault to Kubernetes
303+
// Handle getting and formating Azure Key Vault Secret containing multiple values from Azure Key Vault to Kubernetes
304304
func (h *azureMultiValueSecretHandler) HandleConfigMap() (map[string]string, error) {
305305
values := make(map[string]string)
306306

0 commit comments

Comments
 (0)