Skip to content

Commit

Permalink
up: tooling: k8s, kubebuilder, golang and more (#132)
Browse files Browse the repository at this point in the history
* upgrade all tooling: k8s, kubebuilder, golang and more

* move source code to allign with latest kubebuilder

* fix tests

* Fix typo

* Fix helm templates

* Fix typo
  • Loading branch information
isindir authored Apr 18, 2023
1 parent 10e9faa commit 0805922
Show file tree
Hide file tree
Showing 21 changed files with 246 additions and 252 deletions.
14 changes: 7 additions & 7 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,23 +19,23 @@ jobs:
image: ubuntu-2204:2023.02.1
environment: &versions
# https://github.com/kubernetes/kubernetes/releases
KUBECTL_VERSION: v1.26.2
KUBECTL_VERSION: v1.26.4
# https://hub.docker.com/r/rancher/k3s/tags
K3S_VERSION: v1.26.1-k3s1
# https://github.com/rancher/k3d/releases
K3D_VERSION: v5.4.8
K3D_VERSION: v5.4.9
# https://github.com/helm/helm/releases
HELM_VERSION: v3.11.2
HELM_VERSION: v3.11.3
# https://golang.org/dl/
GOLANG_VERSION: "1.20.2"
GOLANG_VERSION: "1.20.3"
# https://github.com/kubernetes-sigs/kubebuilder/releases
KUBEBUILDER_VERSION: 3.9.1
KUBEBUILDER_VERSION: 3.10.0
# https://github.com/mozilla/sops/releases
SOPS_VERSION: v3.7.3
# https://github.com/kubernetes-sigs/kustomize/releases
KUSTOMIZE_VERSION: v5.0.0
KUSTOMIZE_VERSION: v5.0.1
# https://github.com/helm-unittest/helm-unittest/releases
HELM_UNITTEST_VERSION: 0.3.0
HELM_UNITTEST_VERSION: 0.3.1
# https://github.com/instrumenta/kubeval/releases
KUBEVAL_VERSION: 0.16.1
# https://github.com/github/hub/releases
Expand Down
12 changes: 6 additions & 6 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# UPDATE_HERE
# https://github.com/kubernetes-sigs/kubebuilder/releases
kubebuilder 3.9.1
kubebuilder 3.10.0
# https://golang.org/dl/
golang 1.20.2
golang 1.20.3
# https://github.com/mozilla/sops/releases
sops 3.7.3
# https://github.com/kubernetes-sigs/kustomize/releases
kustomize 5.0.0
kustomize 5.0.1
# https://github.com/rancher/k3d/releases
k3d 5.4.8
k3d 5.4.9
# https://github.com/kubernetes/kubernetes/releases
kubectl 1.26.2
kubectl 1.26.4
# https://github.com/helm/helm/releases
helm 3.11.2
helm 3.11.3
# https://github.com/norwoodj/helm-docs/releases
helm-docs 1.11.0
# https://github.com/instrumenta/kubeval/releases
Expand Down
10 changes: 5 additions & 5 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Build the manager binary
# https://www.debian.org/releases/
# https://hub.docker.com/_/golang/tags?page=1&name=bullseye
FROM golang:1.20.2-bullseye as builder
FROM golang:1.20.3-bullseye as builder

WORKDIR /workspace
# Copy the Go Modules manifests
Expand All @@ -13,16 +13,16 @@ COPY go.sum go.sum
RUN go mod download

# Copy the go source
COPY main.go main.go
COPY cmd/ cmd/
COPY api/ api/
COPY controllers/ controllers/
COPY internal/ internal/

# Build (GOARCH=amd64)
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -o manager main.go
RUN CGO_ENABLED=0 GO111MODULE=on go build -a -o manager cmd/main.go

# https://wiki.ubuntu.com/Releases
# https://hub.docker.com/_/ubuntu/tags?page=1&name=jammy
FROM ubuntu:jammy-20230301
FROM ubuntu:jammy-20230308

RUN apt-get -y update \
&& apt-get -y upgrade \
Expand Down
12 changes: 6 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
# UPDATE_HERE
GO := GOPROXY=https://proxy.golang.org go
SOPS_SEC_OPERATOR_VERSION := 0.8.1
SOPS_SEC_OPERATOR_VERSION := 0.8.2

# https://github.com/kubernetes-sigs/controller-tools/releases
CONTROLLER_GEN_VERSION := "v0.11.3"
# https://github.com/kubernetes-sigs/controller-runtime/releases
CONTROLLER_RUNTIME_VERSION := "v0.14.5"
CONTROLLER_RUNTIME_VERSION := "v0.14.6"
# https://github.com/kubernetes-sigs/kustomize/releases
KUSTOMIZE_VERSION := "v5.0.0"
KUSTOMIZE_VERSION := "v5.0.1"
# use `setup-envtest list` to obtain the list of available versions
# until fixed, can't use newer version, see:
# https://github.com/kubernetes-sigs/controller-runtime/issues/1571
Expand Down Expand Up @@ -128,7 +128,7 @@ vet: ## Run go vet against code.

.PHONY: test
test: clean generate fmt vet envtest ## Run tests.
SOPS_AGE_RECIPIENTS="age1pnmp2nq5qx9z4lpmachyn2ld07xjumn98hpeq77e4glddu96zvms9nn7c8" SOPS_AGE_KEY_FILE="${PWD}/config/age-test-key/key-file.txt" KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path --force)" $(GO) test ./... -coverpkg=./controllers/... -coverprofile=$(TMP_COVER_FILE)
SOPS_AGE_RECIPIENTS="age1pnmp2nq5qx9z4lpmachyn2ld07xjumn98hpeq77e4glddu96zvms9nn7c8" SOPS_AGE_KEY_FILE="${PWD}/config/age-test-key/key-file.txt" KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) -p path --force)" $(GO) test ./... -coverpkg=./internal/controllers/... -coverprofile=$(TMP_COVER_FILE)

cover: test ## Run tests with coverage.
$(GO) tool cover -func=$(TMP_COVER_FILE)
Expand All @@ -138,11 +138,11 @@ cover: test ## Run tests with coverage.

.PHONY: build
build: generate fmt vet ## Build manager binary.
$(GO) build -o bin/manager main.go
$(GO) build -o bin/manager cmd/main.go

.PHONY: run
run: generate fmt vet ## Run a controller from your host.
$(GO) run ./main.go
$(GO) run ./cmd/main.go

docker-login: ## Performs logging to dockerhub using DOCKERHUB_USERNAME and DOCKERHUB_PASS environment variables.
echo "${DOCKERHUB_PASS}" | base64 -d | docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
Expand Down
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
[![Go Report Card](https://goreportcard.com/badge/github.com/isindir/sops-secrets-operator?)](https://goreportcard.com/report/github.com/isindir/sops-secrets-operator)
[![github.com/isindir/sops-secrets-operator](/advisor/golang/github.com/isindir/sops-secrets-operator/badge.svg)](/advisor/golang/github.com/isindir/sops-secrets-operator)
[![CircleCI](https://circleci.com/gh/isindir/sops-secrets-operator.svg?style=svg)](https://circleci.com/gh/isindir/sops-secrets-operator)
[![GitHub release](https://img.shields.io/github/tag/isindir/sops-secrets-operator.svg)](https://github.com/isindir/sops-secrets-operator/releases)
[![Docker pulls](https://img.shields.io/docker/pulls/isindir/sops-secrets-operator.svg)](https://hub.docker.com/r/isindir/sops-secrets-operator)
Expand All @@ -23,7 +24,7 @@ encrypted files stored in `git` repository.

| Kubernetes | Sops | Chart | Operator |
|---|---|---|---|
| v1.26.x | v3.7.3 | 0.14.1 | 0.8.1 |
| v1.26.x | v3.7.3 | 0.14.2 | 0.8.2 |
| v1.25.x | v3.7.3 | 0.12.5 | 0.6.4 |
| v1.24.x | v3.7.3 | 0.11.3 | 0.5.3 |
| v1.23.x | v3.7.2 | 0.10.8 | 0.4.8 |
Expand Down
4 changes: 2 additions & 2 deletions chart/helm3/sops-secrets-operator/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: v2
# UPDATE_HERE
version: 0.14.1
appVersion: 0.8.1
version: 0.14.2
appVersion: 0.8.2
type: application
description: Helm chart deploys sops-secrets-operator
name: sops-secrets-operator
Expand Down
2 changes: 1 addition & 1 deletion chart/helm3/sops-secrets-operator/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CHART_NAME?=$(shell cat Chart.yaml | awk 'BEGIN { FS=": " } $$0~/^name:/ { gsub(
VERSION_TAG?=$(shell cat Chart.yaml | awk 'BEGIN { FS=": " } $$0~/^version/ { gsub(/['\'',]/, ""); print $$2; }')

# UPDATE_HERE
K8S_VERSION := "1.26.2"
K8S_VERSION := "1.26.4"

SHELL=/bin/bash

Expand Down
4 changes: 2 additions & 2 deletions chart/helm3/sops-secrets-operator/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,11 @@ The following table lists the configurable parameters of the Sops-secrets-operat
| healthProbes.readiness | object | `{"initialDelaySeconds":5,"periodSeconds":10}` | Readiness probe configuration |
| image.pullPolicy | string | `"Always"` | Operator image pull policy |
| image.repository | string | `"isindir/sops-secrets-operator"` | Operator image name |
| image.tag | string | `"0.8.1"` | Operator image tag |
| image.tag | string | `"0.8.2"` | Operator image tag |
| imagePullSecrets | list | `[]` | Secrets to pull image from private docker repository |
| initImage.pullPolicy | string | `"Always"` | Init container image pull policy |
| initImage.repository | string | `"ubuntu"` | Init container image name |
| initImage.tag | string | `"jammy-20230301"` | Init container image tag |
| initImage.tag | string | `"jammy-20230308"` | Init container image tag |
| kubeconfig | object | `{"enabled":false,"path":null}` | Paths to a kubeconfig. Only required if out-of-cluster. |
| logging | object | `{"encoder":"json","level":"info","stacktraceLevel":"error"}` | Logging configuration section suggested values Development Mode (encoder=consoleEncoder,logLevel=Debug,stackTraceLevel=Warn). Production Mode (encoder=jsonEncoder,logLevel=Info,stackTraceLevel=Error) (default) |
| logging.encoder | string | `"json"` | Zap log encoding (one of 'json' or 'console') |
Expand Down
2 changes: 0 additions & 2 deletions chart/helm3/sops-secrets-operator/templates/azure_secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ metadata:
name: {{ include "sops-secrets-operator.name" . }}-azure-secret
labels:
{{ include "sops-secrets-operator.labels" . | indent 4 }}
app.kubernetes.io/name: {{ include "sops-secrets-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
type: Opaque
stringData:
tenantId: {{ .Values.azure.tenantId }}
Expand Down
2 changes: 0 additions & 2 deletions chart/helm3/sops-secrets-operator/templates/gcp_secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ metadata:
{{- end }}
labels:
{{ include "sops-secrets-operator.labels" . | indent 4 }}
app.kubernetes.io/name: {{ include "sops-secrets-operator.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
type: Opaque
stringData:
key.json: |-
Expand Down
8 changes: 4 additions & 4 deletions chart/helm3/sops-secrets-operator/tests/operator_test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ tests:
app.kubernetes.io/instance: sops
app.kubernetes.io/managed-by: Helm
app.kubernetes.io/name: sops-secrets-operator
app.kubernetes.io/version: 0.8.1
helm.sh/chart: sops-secrets-operator-0.14.1
app.kubernetes.io/version: 0.8.2
helm.sh/chart: sops-secrets-operator-0.14.2

# custom name
- it: should correctly render custome name
Expand Down Expand Up @@ -170,7 +170,7 @@ tests:
# UPDATE_HERE
- equal:
path: spec.template.spec.containers[0].image
value: isindir/sops-secrets-operator:0.8.1
value: isindir/sops-secrets-operator:0.8.2
- equal:
path: spec.template.spec.containers[0].imagePullPolicy
value: Always
Expand Down Expand Up @@ -198,7 +198,7 @@ tests:
- equal:
path: spec.template.spec.initContainers[0].image
# UPDATE_HERE
value: ubuntu:jammy-20230301
value: ubuntu:jammy-20230308
- equal:
path: spec.template.spec.initContainers[0].imagePullPolicy
value: Always
Expand Down
4 changes: 2 additions & 2 deletions chart/helm3/sops-secrets-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ image:
# -- Operator image name
repository: isindir/sops-secrets-operator
# -- Operator image tag
tag: 0.8.1
tag: 0.8.2
# -- Operator image pull policy
pullPolicy: Always

Expand All @@ -22,7 +22,7 @@ initImage:
# -- Init container image name
repository: ubuntu
# -- Init container image tag
tag: jammy-20230301
tag: jammy-20230308
# -- Init container image pull policy
pullPolicy: Always

Expand Down
2 changes: 1 addition & 1 deletion main.go → cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (
isindirv1alpha1 "github.com/isindir/sops-secrets-operator/api/v1alpha1"
isindirv1alpha2 "github.com/isindir/sops-secrets-operator/api/v1alpha2"
isindirv1alpha3 "github.com/isindir/sops-secrets-operator/api/v1alpha3"
"github.com/isindir/sops-secrets-operator/controllers"
"github.com/isindir/sops-secrets-operator/internal/controllers"
//+kubebuilder:scaffold:imports
)

Expand Down
Loading

0 comments on commit 0805922

Please sign in to comment.