diff --git a/charts/tf-controller/Chart.yaml b/charts/tf-controller/Chart.yaml index 460a8d26..5a69b036 100644 --- a/charts/tf-controller/Chart.yaml +++ b/charts/tf-controller/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: tf-controller description: The Helm chart for Weave GitOps Terraform Controller type: application -version: 0.16.0-rc.1 -appVersion: "v0.16.0-rc.1" +version: 0.16.0-rc.2 +appVersion: "v0.16.0-rc.2" diff --git a/charts/tf-controller/README.md b/charts/tf-controller/README.md index f421b33b..2410042c 100644 --- a/charts/tf-controller/README.md +++ b/charts/tf-controller/README.md @@ -1,6 +1,6 @@ # Weave GitOps Terraform Controller -![Version: 0.16.0-rc.1](https://img.shields.io/badge/Version-0.16.0--rc.1-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.16.0-rc.1](https://img.shields.io/badge/AppVersion-v0.16.0--rc.1-informational?style=flat-square) +![Version: 0.16.0-rc.2](https://img.shields.io/badge/Version-0.16.0--rc.2-informational?style=flat-square) ![Type: application](https://img.shields.io/badge/Type-application-informational?style=flat-square) ![AppVersion: v0.16.0-rc.2](https://img.shields.io/badge/AppVersion-v0.16.0--rc.2-informational?style=flat-square) The Helm chart for Weave GitOps Terraform Controller @@ -72,7 +72,7 @@ __Note__: If you need to use the `imagePullSecrets` it would be best to set `ser | rbac.create | bool | `true` | If `true`, create and use RBAC resources | | replicaCount | int | `1` | Number of TF-Controller pods to deploy | | resources | object | `{"limits":{"cpu":"1000m","memory":"1Gi"},"requests":{"cpu":"200m","memory":"64Mi"}}` | Resource limits and requests | -| runner | object | `{"creationTimeout":"5m0s","grpc":{"maxMessageSize":4},"image":{"repository":"ghcr.io/weaveworks/tf-runner","tag":"v0.16.0-rc.1"},"serviceAccount":{"allowedNamespaces":[],"annotations":{},"create":true,"name":""}}` | Runner-specific configurations | +| runner | object | `{"creationTimeout":"5m0s","grpc":{"maxMessageSize":4},"image":{"repository":"ghcr.io/weaveworks/tf-runner","tag":"v0.16.0-rc.2"},"serviceAccount":{"allowedNamespaces":[],"annotations":{},"create":true,"name":""}}` | Runner-specific configurations | | runner.creationTimeout | string | `"5m0s"` | Timeout for runner-creation (Controller) | | runner.grpc.maxMessageSize | int | `4` | Maximum GRPC message size (Controller) | | runner.image.repository | string | `"ghcr.io/weaveworks/tf-runner"` | Runner image repository | diff --git a/charts/tf-controller/templates/_helpers.tpl b/charts/tf-controller/templates/_helpers.tpl index b714e35b..55658f46 100644 --- a/charts/tf-controller/templates/_helpers.tpl +++ b/charts/tf-controller/templates/_helpers.tpl @@ -87,7 +87,7 @@ Create a unique list of runner allowed namespaces Expand the name of the chart. */}} {{- define "planner.name" -}} -{{- printf "%s-planner" (default .Chart.Name .Values.nameOverride) | trunc 63 | trimSuffix "-" }} +{{ include "tf-controller.name" . }}-branch-planner {{- end }} {{/* @@ -96,16 +96,7 @@ We truncate at 63 chars because some Kubernetes name fields are limited to this If release name contains chart name it will be used as a full name. */}} {{- define "planner.fullname" -}} -{{- if .Values.fullnameOverride }} -{{- printf "%s-planner" .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- $name := printf "%s-planner" (default .Chart.Name .Values.nameOverride) }} -{{- if contains $name .Release.Name }} -{{- printf "%s-planner" .Release.Name | trunc 63 | trimSuffix "-" }} -{{- else }} -{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} -{{- end }} -{{- end }} +{{ include "tf-controller.fullname" . }}-branch-planner {{- end }} {{/* diff --git a/charts/tf-controller/values.yaml b/charts/tf-controller/values.yaml index 5d625a50..e833586b 100644 --- a/charts/tf-controller/values.yaml +++ b/charts/tf-controller/values.yaml @@ -27,7 +27,7 @@ image: pullPolicy: IfNotPresent # -- Overrides the image tag whose default is the chart appVersion. # @default -- `.Chart.AppVersion` - tag: "v0.16.0-rc.1" + tag: "v0.16.0-rc.2" # -- Controller image pull secret imagePullSecrets: [] # -- Resource limits and requests @@ -114,7 +114,7 @@ runner: repository: ghcr.io/weaveworks/tf-runner # -- Runner image tag # @default -- `.Chart.AppVersion` - tag: "v0.16.0-rc.1" + tag: "v0.16.0-rc.2" grpc: # -- Maximum GRPC message size (Controller) maxMessageSize: 4 diff --git a/config/branch-planner/kustomization.yaml b/config/branch-planner/kustomization.yaml index 2b48b768..9fa75476 100644 --- a/config/branch-planner/kustomization.yaml +++ b/config/branch-planner/kustomization.yaml @@ -8,4 +8,4 @@ generatorOptions: images: - name: weaveworks/branch-planner newName: ghcr.io/weaveworks/branch-planner - newTag: v0.16.0-rc.1 + newTag: v0.16.0-rc.2 diff --git a/config/manager/kustomization.yaml b/config/manager/kustomization.yaml index e6b7f868..06fe987c 100644 --- a/config/manager/kustomization.yaml +++ b/config/manager/kustomization.yaml @@ -8,4 +8,4 @@ generatorOptions: images: - name: weaveworks/tf-controller newName: ghcr.io/weaveworks/tf-controller - newTag: v0.16.0-rc.1 + newTag: v0.16.0-rc.2 diff --git a/docs/branch_planner/rc.yaml b/docs/branch_planner/rc.yaml index daa24081..335a2e4e 100644 --- a/docs/branch_planner/rc.yaml +++ b/docs/branch_planner/rc.yaml @@ -21,16 +21,20 @@ spec: sourceRef: kind: HelmRepository name: tf-controller - version: '>=0.15.0-rc.6' + version: '>=0.16.0-rc.2' interval: 1h0s releaseName: tf-controller targetNamespace: flux-system install: crds: Create + remediation: + retries: -1 upgrade: crds: CreateReplace + remediation: + retries: -1 values: - replicaCount: 1 + replicaCount: 3 concurrency: 24 resources: limits: @@ -42,11 +46,16 @@ spec: caCertValidityDuration: 24h certRotationCheckFrequency: 30m image: - tag: v0.15.0-rc.6 + tag: v0.16.0-rc.2 runner: image: - tag: v0.15.0-rc.6 + tag: v0.16.0-rc.2 + grpc: + maxMessageSize: 30 branchPlanner: enabled: true image: - tag: v0.15.0-rc.6 + tag: v0.16.0-rc.2 + configMap: + name: branch-planner + create: true diff --git a/docs/branch_planner/release.yaml b/docs/branch_planner/release.yaml index 3df28904..335a2e4e 100644 --- a/docs/branch_planner/release.yaml +++ b/docs/branch_planner/release.yaml @@ -21,7 +21,7 @@ spec: sourceRef: kind: HelmRepository name: tf-controller - version: '>=0.16.0-rc.1' + version: '>=0.16.0-rc.2' interval: 1h0s releaseName: tf-controller targetNamespace: flux-system @@ -46,13 +46,16 @@ spec: caCertValidityDuration: 24h certRotationCheckFrequency: 30m image: - tag: v0.16.0-rc.1 + tag: v0.16.0-rc.2 runner: image: - tag: v0.16.0-rc.1 + tag: v0.16.0-rc.2 grpc: maxMessageSize: 30 branchPlanner: enabled: true image: - tag: v0.16.0-rc.1 + tag: v0.16.0-rc.2 + configMap: + name: branch-planner + create: true diff --git a/docs/release.yaml b/docs/release.yaml index e6213690..8341d678 100644 --- a/docs/release.yaml +++ b/docs/release.yaml @@ -21,7 +21,7 @@ spec: sourceRef: kind: HelmRepository name: tf-controller - version: '>=0.16.0-rc.1' + version: '>=0.16.0-rc.2' interval: 1h0s releaseName: tf-controller targetNamespace: flux-system @@ -46,9 +46,9 @@ spec: caCertValidityDuration: 24h certRotationCheckFrequency: 30m image: - tag: v0.16.0-rc.1 + tag: v0.16.0-rc.2 runner: image: - tag: v0.16.0-rc.1 + tag: v0.16.0-rc.2 grpc: maxMessageSize: 30 diff --git a/internal/config/config.go b/internal/config/config.go index bd078f35..e1b1625a 100644 --- a/internal/config/config.go +++ b/internal/config/config.go @@ -8,6 +8,7 @@ import ( "gopkg.in/yaml.v2" corev1 "k8s.io/api/core/v1" + "k8s.io/apimachinery/pkg/api/errors" "k8s.io/apimachinery/pkg/types" "sigs.k8s.io/controller-runtime/pkg/client" ) @@ -21,7 +22,8 @@ const ( AnnotationErrorRevision = "infra.weave.works/error-revision" // DefaultNamespace will be used if RUNTIME_NAMESPACE is not defined. - DefaultNamespace = "flux-system" + DefaultNamespace = "flux-system" + DefaultTokenSecretName = "branch-planner-token" ) // Example ConfigMap @@ -34,7 +36,7 @@ const ( // metadata: // name: branch-based-planner // data: -// # Secret to use to use GitHub API. +// # Secret to use GitHub API. // # Key in the secret: token // secretNamespace: flux-system // secretName: bbp-token @@ -56,23 +58,39 @@ type Config struct { Labels map[string]string } -func ReadConfig(ctx context.Context, clusterClient client.Client, ref types.NamespacedName) (Config, error) { - config := Config{} - - if ref.Namespace == "" { - ref.Namespace = RuntimeNamespace() +func ReadConfig(ctx context.Context, clusterClient client.Client, configMapObjectKey types.NamespacedName) (Config, error) { + if configMapObjectKey.Namespace == "" { + configMapObjectKey.Namespace = RuntimeNamespace() } - configMap := &corev1.ConfigMap{} - err := clusterClient.Get(ctx, ref, configMap) + err := clusterClient.Get(ctx, configMapObjectKey, configMap) if err != nil { + defaultConfig := Config{ + SecretName: DefaultTokenSecretName, + SecretNamespace: RuntimeNamespace(), + Resources: []client.ObjectKey{ + {Namespace: RuntimeNamespace()}, + }, + } + + // Check for not found error, it's ok to not have a ConfigMap + if errors.IsNotFound(err) { + return defaultConfig, nil + } + + // Check for permission error, it's ok to not have access to the ConfigMap + if errors.IsForbidden(err) { + return defaultConfig, nil + } + + // Return a generic error for other cases return Config{}, fmt.Errorf("unable to get ConfigMap: %w", err) } + config := Config{} config.SecretNamespace = configMap.Data["secretNamespace"] config.SecretName = configMap.Data["secretName"] resourceData := configMap.Data["resources"] - if config.SecretNamespace == "" { config.SecretNamespace = RuntimeNamespace() }