Skip to content

Commit 5088c40

Browse files
authored
Update for helm charts to use latest ecr-public repository. (#136)
Issue #, if available: aws-controllers-k8s/community#829 Description of changes: * Update `build-controller-release` script to use latest ecr-public repository as image repository * Update Chart.yaml.tpl for chart name so that helm charts can be properly added as dependencies. (Fixing helm chart semver issue) * Update values.yaml.tpl to form image url correctly due to latest changes ------ make test successful ``` ➜ code-generator git:(new-ecr) make test go test -tags codegen ./... ? github.com/aws-controllers-k8s/code-generator/cmd/ack-generate [no test files] ? github.com/aws-controllers-k8s/code-generator/cmd/ack-generate/command [no test files] ok github.com/aws-controllers-k8s/code-generator/pkg/generate/ack 0.883s ok github.com/aws-controllers-k8s/code-generator/pkg/generate/code (cached) ? github.com/aws-controllers-k8s/code-generator/pkg/generate/config [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/generate/crossplane [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/generate/olm [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/generate/templateset [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/metadata [no test files] ok github.com/aws-controllers-k8s/code-generator/pkg/model (cached) ok github.com/aws-controllers-k8s/code-generator/pkg/model/multiversion (cached) ok github.com/aws-controllers-k8s/code-generator/pkg/names (cached) ? github.com/aws-controllers-k8s/code-generator/pkg/testutil [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/util [no test files] ? github.com/aws-controllers-k8s/code-generator/pkg/version [no test files] ``` ------ latest generated ecr dummy helm artifacts: ``` ➜ code-generator git:(new-ecr) ✗ ./scripts/build-controller-release.sh ecr v0.0.9 Building release artifacts for ecr-v0.0.9 Generating common custom resource definitions Generating custom resource definitions for ecr Generating RBAC manifests for ecr ``` ``` Chart.yaml apiVersion: v1 name: ecr-chart description: A Helm chart for the ACK service controller for ecr version: v0.0.9 appVersion: v0.0.9 home: https://github.com/aws-controllers-k8s/ecr-controller icon: https://raw.githubusercontent.com/aws/eks-charts/master/docs/logo/aws.png sources: - https://github.com/aws-controllers-k8s/ecr-controller maintainers: - name: ACK Admins url: https://github.com/orgs/aws-controllers-k8s/teams/ack-admin - name: ecr Admins url: https://github.com/orgs/aws-controllers-k8s/teams/ecr-maintainer keywords: - aws - kubernetes - ecr ``` ``` values.yaml # Default values for ack-ecr-controller. # This is a YAML-formatted file. # Declare variables to be passed into your templates. image: repository: public.ecr.aws/u2r4f3v7/ecr-controller tag: v0.0.9 pullPolicy: IfNotPresent pullSecrets: [] nameOverride: "" fullnameOverride: "" deployment: annotations: {} labels: {} containerPort: 8080 metrics: service: # Set to true to automatically create a Kubernetes Service resource for the # Prometheus metrics server endpoint in controller create: false # Which Type to use for the Kubernetes Service? # See: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types type: "ClusterIP" resources: requests: memory: "64Mi" cpu: "50m" limits: memory: "128Mi" cpu: "100m" aws: # If specified, use the AWS region for AWS API calls region: "" account_id: "" endpoint_url: "" # log level for the controller log: enable_development_logging: false level: info # If specified, the service controller will watch for object creation only in the provided namespace watchNamespace: "" resourceTags: # Configures the ACK service controller to always set key/value pairs tags on resources that it manages. - services.k8s.aws/managed=true - services.k8s.aws/created=%UTCNOW% - services.k8s.aws/namespace=%KUBERNETES_NAMESPACE% serviceAccount: # Specifies whether a service account should be created create: true # The name of the service account to use. name: ack-ecr-controller annotations: {} # eks.amazonaws.com/role-arn: arn:aws:iam::AWS_ACCOUNT_ID:role/IAM_ROLE_NAME ``` By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
1 parent 8180301 commit 5088c40

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

cmd/ack-generate/command/release.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ var releaseCmd = &cobra.Command{
4040

4141
func init() {
4242
releaseCmd.PersistentFlags().StringVar(
43-
&optImageRepository, "image-repository", "amazon/aws-controllers-k8s", "the Docker image repository to use in release artifacts.",
43+
&optImageRepository, "image-repository", "", "the Docker image repository to use in release artifacts. Defaults to 'public.ecr.aws/aws-controllers-k8s/$service-controller'",
4444
)
4545
releaseCmd.PersistentFlags().StringVar(
4646
&optServiceAccountName, "service-account-name", "default", "The name of the ServiceAccount AND ClusterRole used for ACK service controller",
@@ -61,6 +61,9 @@ func generateRelease(cmd *cobra.Command, args []string) error {
6161
if optReleaseOutputPath == "" {
6262
optReleaseOutputPath = filepath.Join(optServicesDir, svcAlias)
6363
}
64+
if optImageRepository == "" {
65+
optImageRepository = fmt.Sprintf("public.ecr.aws/aws-controllers-k8s/%s-controller", svcAlias)
66+
}
6467
// TODO(jaypipes): We could do some git-fu here to verify that the release
6568
// version supplied hasn't been used (as a Git tag) before...
6669
releaseVersion := strings.ToLower(args[1])

scripts/build-controller-release.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ set -eo pipefail
88
SCRIPTS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
99
ROOT_DIR="$SCRIPTS_DIR/.."
1010
BIN_DIR="$ROOT_DIR/bin"
11-
DEFAULT_IMAGE_REPOSITORY="public.ecr.aws/aws-controllers-k8s/controller"
1211
ACK_GENERATE_OLM=${ACK_GENERATE_OLM:-"false"}
1312

1413
source "$SCRIPTS_DIR/lib/common.sh"
@@ -35,7 +34,6 @@ ACK_GENERATE_BIN_PATH=${ACK_GENERATE_BIN_PATH:-$DEFAULT_ACK_GENERATE_BIN_PATH}
3534
ACK_GENERATE_API_VERSION=${ACK_GENERATE_API_VERSION:-"v1alpha1"}
3635
ACK_GENERATE_CONFIG_PATH=${ACK_GENERATE_CONFIG_PATH:-""}
3736
ACK_METADATA_CONFIG_PATH=${ACK_METADATA_CONFIG_PATH:-""}
38-
ACK_GENERATE_IMAGE_REPOSITORY=${ACK_GENERATE_IMAGE_REPOSITORY:-"$DEFAULT_IMAGE_REPOSITORY"}
3937
AWS_SDK_GO_VERSION=${AWS_SDK_GO_VERSION:-"v1.35.5"}
4038

4139
DEFAULT_TEMPLATES_DIR="$ROOT_DIR/../../aws-controllers-k8s/code-generator/templates"
@@ -82,7 +80,7 @@ Environment variables:
8280
Default: services/{SERVICE}
8381
ACK_GENERATE_IMAGE_REPOSITORY: Specify a Docker image repository to use
8482
for release artifacts
85-
Default: $DEFAULT_IMAGE_REPOSITORY
83+
Default: public.ecr.aws/u2r4f3v7/{SERVICE}-controller
8684
ACK_GENERATE_SERVICE_ACCOUNT_NAME: Name of the Kubernetes Service Account and
8785
Cluster Role to use in Helm chart.
8886
Default: $ACK_GENERATE_SERVICE_ACCOUNT_NAME
@@ -124,6 +122,10 @@ SERVICE=$(echo "$1" | tr '[:upper:]' '[:lower:]')
124122
DEFAULT_SERVICE_CONTROLLER_SOURCE_PATH="$ROOT_DIR/../$SERVICE-controller"
125123
SERVICE_CONTROLLER_SOURCE_PATH=${SERVICE_CONTROLLER_SOURCE_PATH:-$DEFAULT_SERVICE_CONTROLLER_SOURCE_PATH}
126124

125+
# TODO(vijat@): replace "u2r4f3v7" with aws-controllers-k8s
126+
DEFAULT_IMAGE_REPOSITORY="public.ecr.aws/u2r4f3v7/$SERVICE-controller"
127+
ACK_GENERATE_IMAGE_REPOSITORY=${ACK_GENERATE_IMAGE_REPOSITORY:-"$DEFAULT_IMAGE_REPOSITORY"}
128+
127129
if [[ ! -d $SERVICE_CONTROLLER_SOURCE_PATH ]]; then
128130
echo "Error evaluating SERVICE_CONTROLLER_SOURCE_PATH environment variable:" 1>&2
129131
echo "$SERVICE_CONTROLLER_SOURCE_PATH is not a directory." 1>&2

templates/helm/Chart.yaml.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
apiVersion: v1
2-
name: ack-{{ .ServiceIDClean }}-controller
2+
name: {{ .ServiceIDClean }}-chart
33
description: A Helm chart for the ACK service controller for {{ .ServiceIDClean }}
44
version: {{ .ReleaseVersion }}
55
appVersion: {{ .ReleaseVersion }}

templates/helm/values.yaml.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
image:
66
repository: {{ .ImageRepository }}
7-
tag: {{ .ServiceIDClean }}-{{ .ReleaseVersion }}
7+
tag: {{ .ReleaseVersion }}
88
pullPolicy: IfNotPresent
99
pullSecrets: []
1010

0 commit comments

Comments
 (0)