Skip to content

Commit 613bc84

Browse files
authored
Merge pull request #584 from jaypipes/helm
Signed-off-by: Michael Hausenblas <[email protected]>
2 parents a8896c7 + 0ff170c commit 613bc84

File tree

11 files changed

+194
-112
lines changed

11 files changed

+194
-112
lines changed

docs/contents/dev-docs/release.md

Lines changed: 90 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,9 @@ release version for the controller along with the AWS service. For example,
3232
assume a release semver tag of `v0.1.0` that includes service controllers for
3333
S3 and SNS. There would be two Docker images built for this release, one each
3434
containing the ACK service controllers for S3 and SNS. The Docker images would
35-
have the following image tags: `s3-controller-v0.1.0` and
36-
`sns-controller-v0.1.0`. Note that the full image name would be
37-
`amazon/aws-controllers-k8s:s3-v0.1.0`
35+
have the following image tags: `s3-v0.1.0` and `sns-v0.1.0`. Note
36+
that the full image name would be
37+
`public.ecr.aws/aws-controllers-k8s/controller:s3-v0.1.0`
3838

3939
The Helm chart artifact can be used to install the ACK service controller as a
4040
Kubernetes Deployment; the Deployment's Pod image will refer to the exact
@@ -86,19 +86,100 @@ git commit -a -m "release artifacts for release $RELEASE_VERSION"
8686

8787
5. Get your pull request reviewed and merged.
8888

89-
6. Upon merging the pull request, a Github Action should trigger that does the
90-
following:
89+
6. Upon merging the pull request
9190

9291
```bash
9392
git tag -a $RELEASE_VERSION $( git rev-parse HEAD )
9493
git push upstream main --tags
9594
```
9695

96+
!!! todo
97+
A Github Action should execute the above
98+
9799
which will end up associating a Git tag (and therefore a Github release) with
98100
the SHA1 commit ID of the source code for the controllers and the release
99101
artifacts you built for that release version.
100102

101-
The same Github Action should run the `scripts/publish-controller-images.sh`
102-
script to build the Docker images for the service controllers included in the
103-
release and push the images to the `amazon/aws-controllers-k8s` image
104-
repository.
103+
7. Publish the controller images
104+
105+
First, ensure you are logged in to the ECR public repository:
106+
107+
```bash
108+
aws --profile ecrpush ecr-public get-login-password --region us-east-1 | docker login -u AWS --password-stdin public.ecr.aws
109+
Login Succeeded
110+
```
111+
112+
!!! note
113+
Above, I have a set of AWS CLI credentials in a profile called "ecrpush"
114+
that I use for pushing to the ACK public ECR repository. You will need
115+
something similar.
116+
117+
Now publish all the controller images to the ECR public repository for
118+
controller images:
119+
120+
```bash
121+
export DOCKER_REPOSITORY=public.ecr.aws/aws-controllers-k8s/controller
122+
for SERVICE in s3 sns;
123+
do ./scripts/publish-controller-image.sh $SERVICE
124+
done
125+
```
126+
127+
!!! todo
128+
129+
The same Github Action should run the
130+
`scripts/publish-controller-images.sh` script to build the Docker images
131+
for the service controllers included in the release and push the images to
132+
the `public.ecr.aws/aws-controllers-k8s/controller` image repository.
133+
134+
8. Publish the Helm Charts
135+
136+
First, ensure you are logged in to the ECR public repository for Helm:
137+
138+
```bash
139+
aws --profile ecrpush ecr-public get-login-password --region us-east-1 | HELM_EXPERIMENTAL_OCI=1 helm registry login -u AWS --password-stdin public.ecr.aws
140+
Login succeeded
141+
```
142+
143+
!!! note
144+
Above, I have a set of AWS CLI credentials in a profile called "ecrpush"
145+
that I use for pushing to the ACK public ECR repository. You will need
146+
something similar.
147+
148+
Now publish all the controller images to the ECR public repository for
149+
controller images using the `scripts/helm-publish-charts.sh` script:
150+
151+
```bash
152+
RELEASE_VERSION=v0.0.1 ./scripts/helm-publish-charts.sh
153+
Generating Helm chart package for [email protected] ... ref: public.ecr.aws/aws-controllers-k8s/chart:apigatewayv2-v0.0.1
154+
digest: 0e24159c9afb840677ba64e63c19a65a6de2dcc87e80df95b3daf0cdb5c54de6
155+
size: 6.4 KiB
156+
name: ack-apigatewayv2-controller
157+
version: v0.0.1
158+
apigatewayv2-v0.0.1: saved
159+
ok.
160+
The push refers to repository [public.ecr.aws/aws-controllers-k8s/chart]
161+
ref: public.ecr.aws/aws-controllers-k8s/chart:apigatewayv2-v0.0.1
162+
digest: 0e24159c9afb840677ba64e63c19a65a6de2dcc87e80df95b3daf0cdb5c54de6
163+
size: 6.4 KiB
164+
name: ack-apigatewayv2-controller
165+
version: v0.0.1
166+
apigatewayv2-v0.0.1: pushed to remote (1 layer, 6.4 KiB total)
167+
<snip>
168+
Generating Helm chart package for [email protected] ... ref: public.ecr.aws/aws-controllers-k8s/chart:sns-v0.0.1
169+
digest: d5c1a79f85f8c320210c3418e7175da5398fba4e5644cd49f107c19db9e1e6d1
170+
size: 4.0 KiB
171+
name: ack-sns-controller
172+
version: v0.0.1
173+
sns-v0.0.1: saved
174+
ok.
175+
The push refers to repository [public.ecr.aws/aws-controllers-k8s/chart]
176+
ref: public.ecr.aws/aws-controllers-k8s/chart:sns-v0.0.1
177+
digest: d5c1a79f85f8c320210c3418e7175da5398fba4e5644cd49f107c19db9e1e6d1
178+
size: 4.0 KiB
179+
name: ack-sns-controller
180+
version: v0.0.1
181+
sns-v0.0.1: pushed to remote (1 layer, 4.0 KiB total)
182+
```
183+
184+
All services that have had a Helm chart generated from step #2 will have a
185+
corresponding Helm chart pushed to the ECR public repository.

docs/contents/user-docs/install.md

Lines changed: 77 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -10,47 +10,102 @@ In the following we walk you through installing an ACK service controller.
1010
for a particular AWS API.
1111

1212
Each ACK service controller is packaged into a separate container image,
13-
published on the [`amazon/aws-controllers-k8s` DockerHub repository][0].
13+
published on a [public ECR repository][controller-repo].
1414

15-
[0]: https://hub.docker.com/r/amazon/aws-controllers-k8s
15+
[controller-repo]: https://gallery.ecr.aws/aws-controllers-k8s/controller
1616

1717
Individual ACK service controllers are tagged with `$SERVICE-$VERSION` Docker
1818
image tags, allowing you to download/test specific ACK service controllers. For
1919
example, if you wanted to test the `v0.1.0` release image of the ACK service
20-
controller for S3, you would pull the `amazon/aws-controllers-k8s:s3-v0.1.0`
21-
image.
20+
controller for S3, you would pull the
21+
`public.ecr.aws/aws-controllers-k8s/controller:s3-v0.1.0` image.
22+
23+
!!! note "No 'latest' tag"
24+
It is [not good practice][no-latest-tag] to rely on a `:latest` default
25+
image tag. There are actually no images tagged with a `:latest` tag in our
26+
image repositories. You should always specify a `$SERVICE-$VERSION` tag
27+
when referencing an ACK service controller image.
28+
29+
[no-latest-tag]: https://vsupalov.com/docker-latest-tag/
2230

2331
## Helm (recommended)
2432

2533
The recommended way to install an ACK service controller for Kubernetes is to
26-
use Helm 3. Please ensure you have installed Helm 3 to your local environment
27-
before running these steps.
34+
use Helm 3. Please ensure you have [installed Helm 3][install-helm] to your
35+
local environment before running these steps.
2836

29-
Before installing an ACK service controller, ensure you have added the
30-
AWS Controllers for Kubernetes Helm repository:
37+
[install-helm]: https://helm.sh/docs/intro/install/
3138

32-
```
33-
helm repo add ack https://aws.github.io/aws-controllers-k8s/charts
34-
```
39+
Each ACK service controller has a separate Helm chart that installs—as a
40+
Kubernetes `Deployment`—the ACK service controller, necessary custom resource
41+
definitions (CRDs), Kubernetes RBAC manifests, and other supporting artifacts.
42+
43+
To view the Helm charts available for installation, check the ECR public
44+
repository for the [ACK Helm charts][charts-repo]. Click on the "Image tags"
45+
tab and take a note of the Helm chart tag for the service controller and
46+
version you wish to install.
47+
48+
[charts-repo]: https://gallery.ecr.aws/aws-controllers-k8s/chart
3549

36-
Likewise, each ACK service controller has a separate Helm chart that
37-
installs—as a Kubernetes `Deployment`—the ACK service controller, necessary
38-
custom resource definitions (CRDs), Kubernetes RBAC manifests, and other
39-
supporting artifacts.
50+
Before installing a Helm chart, you must first make the Helm chart available on
51+
the deployment host. To do so, use the `helm chart pull` and `helm chart
52+
export` commands:
4053

41-
You may install a particular ACK service controller using the `helm install`
54+
```bash
55+
export HELM_EXPERIMENTAL_OCI=1
56+
export SERVICE=s3
57+
export RELEASE_VERSION=v0.0.1
58+
export CHART_EXPORT_PATH=/tmp/chart
59+
export CHART_REPO=public.ecr.aws/aws-controllers-k8s/chart
60+
export CHART_REF=$CHART_REPO:$SERVICE-$RELEASE_VERSION
61+
62+
mkdir -p $CHART_EXPORT_PATH
63+
64+
helm chart pull $CHART_REF
65+
helm chart export $CHART_REF --destination $CHART_EXPORT_PATH
66+
```
67+
68+
You then install a particular ACK service controller using the `helm install`
4269
CLI command:
4370

71+
```bash
72+
export ACK_K8S_NAMESPACE=ack-system
73+
74+
kubectl create namespace $ACK_K8S_NAMESPACE
75+
76+
helm install --namespace $ACK_K8S_NAMESPACE ack-$SERVICE-controller \
77+
$CHART_EXPORT_PATH/ack-$SERVICE-controller
78+
```
79+
80+
You will see the Helm chart installed:
81+
4482
```
45-
helm install [--namespace $KUBERNETES_NAMESPACE] ack-$SERVICE-controller ack/ack-$SERVICE-controller
83+
$ helm install --namespace $ACK_K8S_NAMESPACE ack-$SERVICE-controller $CHART_EXPORT_PATH/ack-$SERVICE-controller
84+
NAME: ack-s3-controller
85+
LAST DEPLOYED: Thu Dec 17 13:09:17 2020
86+
NAMESPACE: ack-system
87+
STATUS: deployed
88+
REVISION: 1
89+
TEST SUITE: None
4690
```
4791

48-
for example, if you wanted to install the latest ACK service controller for S3
49-
into the "ack-system" Kubernetes namespace, you would execute:
92+
You may then verify the Helm chart was installed using the `helm list` command:
93+
94+
```bash
95+
helm list --namespace $ACK_K8S_NAMESPACE -o yaml
96+
```
5097

98+
you should see your newly-deployed Helm chart release:
5199

52-
```sh
53-
helm install --namespace ack-system ack-s3-controller ack/ack-s3-controller
100+
```
101+
$ helm list --namespace $ACK_K8S_NAMESPACE -o yaml
102+
- app_version: v0.0.1
103+
chart: ack-s3-controller-v0.0.1
104+
name: ack-s3-controller
105+
namespace: ack-system
106+
revision: "1"
107+
status: deployed
108+
updated: 2020-12-17 13:09:17.309002201 -0500 EST
54109
```
55110

56111
## Static Kubernetes manifests
@@ -64,19 +119,4 @@ release from the [list of releases][1] for AWS Controllers for Kubernetes.
64119

65120
[1]: https://github.com/aws/aws-controllers-k8s/releases
66121

67-
You will see a list of Assets for the release. One of those Assets will be
68-
named `services/$SERVICE/all-resources.yaml`. For example, for the ACK service
69-
controller for S3, there will be an Asset named
70-
`services/s3/all-resources.yaml` attached to the release. Click on the link to
71-
download the YAML file. This YAML file may be fed to `kubectl apply -f`
72-
directly to install the service controller, any CRDs that it manages, and all
73-
necessary Kubernetes RBAC manifests.
74-
75-
For example:
76-
77-
```sh
78-
kubectl apply -f https://github.com/aws/aws-controllers-k8s/releases/download/v0.0.1/services/s3/all-resources.yaml
79-
```
80-
81-
Once you've installed one or more ACK service controllers, make sure to
82-
[configure permissions](../authorization#configure-permissions), next.
122+
TODO(jaypipes)

scripts/build-controller-release.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ SCRIPTS_DIR=$(cd "$(dirname "$0")"; pwd)
99
ROOT_DIR="$SCRIPTS_DIR/.."
1010
BIN_DIR="$ROOT_DIR/bin"
1111
TEMPLATES_DIR="$ROOT_DIR/templates"
12+
DEFAULT_IMAGE_REPOSITORY="public.ecr.aws/aws-controllers-k8s/controller"
1213

1314
source "$SCRIPTS_DIR/lib/common.sh"
1415
source "$SCRIPTS_DIR/lib/k8s.sh"
@@ -28,7 +29,7 @@ fi
2829
: "${ACK_GENERATE_API_VERSION:="v1alpha1"}"
2930
: "${ACK_GENERATE_CONFIG_PATH:=""}"
3031
: "${ACK_GENERATE_OUTPUT_PATH:=""}"
31-
: "${ACK_GENERATE_IMAGE_REPOSITORY:="amazon/aws-controllers-k8s"}"
32+
: "${ACK_GENERATE_IMAGE_REPOSITORY:=$DEFAULT_IMAGE_REPOSITORY}"
3233

3334
USAGE="
3435
Usage:
@@ -57,7 +58,7 @@ Environment variables:
5758
Default: services/{SERVICE}
5859
ACK_GENERATE_IMAGE_REPOSITORY: Specify a Docker image repository to use
5960
for release artifacts
60-
Default: amazon/aws-controllers-k8s
61+
Default: $DEFAULT_IMAGE_REPOSITORY
6162
ACK_GENERATE_SERVICE_ACCOUNT_NAME: Name of the Kubernetes Service Account and
6263
Cluster Role to use in Helm chart.
6364
Default: $ACK_GENERATE_SERVICE_ACCOUNT_NAME

scripts/helm-publish-charts.sh

Lines changed: 17 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,15 @@ set -Eo pipefail
99

1010
SCRIPTS_DIR=$(cd "$(dirname "$0")"; pwd)
1111
ROOT_DIR="$SCRIPTS_DIR/.."
12-
BUILD_DIR="$ROOT_DIR/build"
1312
SERVICES_DIR="$ROOT_DIR/services"
14-
DEFAULT_HELM_REPO_URL="https://aws.github.io/aws-controllers-k8s/charts"
15-
DEFAULT_GH_USER_EMAIL="[email protected]"
16-
DEFAULT_GH_USER_EMAIL="eks-bot"
17-
DEFAULT_GIT_REPOSITORY="https://eks-bot:${GITHUB_TOKEN}@github.com/aws/aws-controllers-k8s.git"
18-
VERSION=$(git describe --tags --always --dirty || echo "unknown")
13+
DEFAULT_HELM_REGISTRY="public.ecr.aws/aws-controllers-k8s"
14+
DEFAULT_HELM_REPO="chart"
15+
DEFAULT_RELEASE_VERSION=$(git describe --tags --always --dirty || echo "unknown")
1916

20-
: "${HELM_REPO_URL:=$DEFAULT_HELM_REPO_URL}"
21-
: "${GH_USER_NAME:=$DEFAULT_GH_USER_NAME}"
22-
: "${GH_USER_EMAIL:=$DEFAULT_GH_USER_EMAIL}"
23-
: "${GIT_REPOSITORY:=$DEFAULT_GIT_REPOSITORY}"
24-
: "${GIT_COMMIT:="false"}"
17+
18+
: "${RELEASE_VERSION:=$DEFAULT_RELEASE_VERSION}"
19+
: "${HELM_REGISTRY:=$DEFAULT_HELM_REGISTRY}"
20+
: "${HELM_REPO:=$DEFAULT_HELM_REPO}"
2521

2622
source "$SCRIPTS_DIR/lib/common.sh"
2723

@@ -32,58 +28,22 @@ Usage:
3228
$(basename "$0")
3329
3430
Environment variables:
35-
HELM_REPO_URL: The URL for the Helm repository.
36-
Default: $DEFAULT_HELM_REPO_URL
37-
GH_USER_NAME: The name of the Github user to use when Git
38-
commit'ing.
39-
Default: $DEFAULT_GH_USER_NAME
40-
GH_USER_EMAIL: The email of the Github user to use when Git
41-
commit'ing.
42-
Default: $DEFAULT_GH_USER_EMAIL
43-
GIT_REPOSITORY: The Git repository URL to commit to.
44-
Default: $DEFAULT_GIT_REPOSITORY
45-
GIT_COMMIT: If false (default), only build the packages and
46-
index. If true, also creates a Git commit and
47-
pushes that commit to an upstream Git repository.
48-
Default: false
31+
RELEASE_VERSION: The semver release version to use.
32+
Default: $DEFAULT_RELEASE_VERSION
33+
HELM_REGISTRY: The name of the Helm registry.
34+
Default: $DEFAULT_HELM_REGISTRY
35+
HELM_REPO: The name of the Helm repository.
36+
Default: $DEFAULT_HELM_REPO
4937
"
5038

51-
CHARTS_DIR=$ROOT_DIR/charts
52-
53-
if [[ $GIT_COMMIT = "false" ]]; then
54-
# On a dry run, we stash the charts in the git-ignored build/ directory.
55-
# For non-dry-run, we use the $ROOT_DIR/charts directory, which in the
56-
# gh-pages branch of the aws/aws-controllers-k8s upstream source repository
57-
# contains the chart packages and index.yaml file.
58-
CHARTS_DIR=$BUILD_DIR/charts
59-
fi
60-
61-
mkdir -p $CHARTS_DIR
62-
63-
export PACKAGE_OUTPUT_PATH="$BUILD_DIR/release/$VERSION"
39+
export HELM_EXPERIMENTAL_OCI=1
6440

6541
for SERVICE_DIR in $SERVICES_DIR/*; do
6642
SERVICE=$( basename $SERVICE_DIR)
6743
if [[ -d "$SERVICES_DIR/$SERVICE/helm" ]]; then
68-
echo -n "Generating Helm chart package for $SERVICE ... "
69-
$SCRIPTS_DIR/helm-package-controller.sh $SERVICE 1>/dev/null || exit 1
44+
echo -n "Generating Helm chart package for $SERVICE@$RELEASE_VERSION ... "
45+
helm chart save $SERVICES_DIR/$SERVICE/helm/ $HELM_REGISTRY/$HELM_REPO:$SERVICE-$RELEASE_VERSION
7046
echo "ok."
47+
helm chart push $HELM_REGISTRY/$HELM_REPO:$SERVICE-$RELEASE_VERSION
7148
fi
7249
done
73-
74-
# We need to place the packages into the Helm repository's root directory.
75-
mv -f $PACKAGE_OUTPUT_PATH/*.tgz $CHARTS_DIR
76-
77-
echo -n "Building index for Helm repo ... "
78-
helm repo index $CHARTS_DIR --url $HELM_REPO_URL 1>/dev/null || exit 1
79-
echo "ok."
80-
81-
if [[ $GIT_COMMIT = "true" ]]; then
82-
git config user.name $GH_USER_NAME
83-
git config user.email $GH_USER_EMAIL
84-
git remote set-url upstream $GIT_REPOSITORY
85-
git checkout gh-pages
86-
git add .
87-
git commit -m "Publish ACK service controller charts for $VERSION"
88-
git push upstream gh-pages
89-
fi

services/apigatewayv2/helm/values.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Declare variables to be passed into your templates.
44

55
image:
6-
repository: amazon/aws-controllers-k8s
6+
repository: public.ecr.aws/aws-controllers-k8s/controller
77
tag: apigatewayv2-v0.0.1
88
pullPolicy: IfNotPresent
99
pullSecrets: []

0 commit comments

Comments
 (0)