Skip to content

Commit 5ef6c3e

Browse files
committed
feat: add semantic-release and Helm chart; push Docker image and Helm chart to ghcr.io
BREAKING CHANGE: not really a breaking change, just bumping to v1.0.0
1 parent 42b94f2 commit 5ef6c3e

Some content is hidden

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

41 files changed

+324
-589
lines changed

.github/workflows/branches.yaml

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,18 @@
1-
name: Build Container (branches)
1+
name: Build docker image on branches
22
on:
33
push:
4-
branches:
5-
- /refs/heads/*
6-
- !master
4+
branches-ignore:
5+
- main
76
jobs:
87
build:
98
name: Docker Build and Publish
109
runs-on: ubuntu-latest
1110
steps:
12-
- name: Check out code into the Go module directory
13-
uses: actions/checkout@v2
11+
- name: Check out code
12+
uses: actions/checkout@v3
1413

15-
- name: Docker build and publish
16-
uses: docker/build-push-action@v1
14+
- name: Docker build
15+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
1716
with:
18-
username: ${{ secrets.DOCKERHUB_USER }}
19-
password: ${{ secrets.DOCKERHUB_PASSWORD }}
20-
repository: logmein/k8s-aws-operator
21-
tag_with_ref: false
22-
tag_with_sha: false
17+
context: .
2318
push: false
24-

.github/workflows/master.yaml

Lines changed: 0 additions & 25 deletions
This file was deleted.

.github/workflows/publish.yaml

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Publish Docker image and Helm chart
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
env:
8+
REGISTRY: ghcr.io
9+
IMAGE_NAME: ${{ github.repository }}
10+
11+
jobs:
12+
build-and-push-image:
13+
name: Buld and push Docker image
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
packages: write
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v3
21+
22+
- name: Log in to the Container registry
23+
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
24+
with:
25+
registry: ${{ env.REGISTRY }}
26+
username: ${{ github.actor }}
27+
password: ${{ secrets.GITHUB_TOKEN }}
28+
29+
- name: Extract metadata (tags, labels) for Docker
30+
id: meta
31+
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
32+
with:
33+
images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
34+
35+
- name: Build and push Docker image
36+
id: build-and-push
37+
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
38+
with:
39+
context: .
40+
push: true
41+
tags: ${{ steps.meta.outputs.tags }}
42+
labels: ${{ steps.meta.outputs.labels }}
43+
outputs:
44+
imageDigest: ${{ steps.build-and-push.outputs.digest }}
45+
46+
build-and-push-chart:
47+
name: Buld and push Helm chart
48+
needs: build-and-push-image
49+
runs-on: ubuntu-latest
50+
permissions:
51+
contents: write
52+
packages: write
53+
steps:
54+
- name: Checkout repository
55+
uses: actions/checkout@v3
56+
57+
- name: Helm login
58+
shell: bash
59+
run: echo ${{ secrets.GITHUB_TOKEN }} | helm registry login -u ${{ github.actor }} --password-stdin ghcr.io
60+
61+
- name: Helm package
62+
shell: bash
63+
run: helm package charts/${{ github.event.repository.name }} --app-version ${{ github.event.release.tag_name }}@${{needs.build-and-push-image.outputs.imageDigest}} --version ${{ github.event.release.tag_name }}-chart
64+
65+
- name: Helm push
66+
shell: bash
67+
run: helm push ${{ github.event.repository.name }}-${{ github.event.release.tag_name }}-chart.tgz oci://ghcr.io/${{ github.repository_owner }}
68+
69+
- name: Helm logout
70+
shell: bash
71+
run: helm registry logout ghcr.io

.github/workflows/release.yaml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
branches:
6+
- 'main'
7+
8+
jobs:
9+
semantic-release:
10+
name: Run semantic-release
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: write
14+
packages: write
15+
issues: write
16+
pull-requests: write
17+
steps:
18+
- name: Checkout
19+
uses: actions/checkout@v3
20+
21+
- name: Semantic Release
22+
uses: cycjimmy/semantic-release-action@071ef4c9640be3700de2aa7f39e8f4038e0269ed
23+
with:
24+
extra_plugins: |
25+
26+
@semantic-release/[email protected]
27+
@semantic-release/[email protected]
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

.releaserc.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
verifyConditions: []
2+
branches:
3+
- main
4+
plugins:
5+
- '@semantic-release/commit-analyzer'
6+
- - '@semantic-release/release-notes-generator'
7+
- preset: conventionalcommits
8+
- - '@semantic-release/changelog'
9+
- changelogFile: CHANGELOG.md
10+
- - '@semantic-release/git'
11+
- assets:
12+
- CHANGELOG.md
13+
message: "chore(release): ${nextRelease.version}\n\n${nextRelease.notes}"

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ deploy: manifests
4747

4848
# Generate manifests e.g. CRD, RBAC etc.
4949
manifests: controller-gen
50-
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=config/crd/bases
50+
$(CONTROLLER_GEN) $(CRD_OPTIONS) rbac:roleName=manager-role webhook paths="./..." output:crd:artifacts:config=charts/k8s-aws-operator/crds
5151

5252
# Run go fmt against code
5353
fmt:

README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22

33
Manage AWS Elastic IPs (EIPs) and Elastic Network Interfaces (ENIs) as Custom Resources in your Kubernetes cluster and assign them your pods.
44

5-
**Warning:** This project is still work in progress. There might be breaking API changes in the future. Use at your own risk.
6-
75
## Requirements
86

97
* Your pod IPs must be allocated from your VPC subnets. This is the default setup on AWS EKS by using the [AWS VPC CNI plugin](https://github.com/aws/amazon-vpc-cni-k8s).
@@ -18,13 +16,14 @@ Create an IAM role with the policy [here](iam/policy.json).
1816

1917
### Install the operator
2018

21-
Ensure that the k8s-aws-operator uses this role, e.g. using [»IAM Roles for Service Accounts« (IRSA)](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html) or [kube2iam](https://github.com/jtblin/kube2iam)/[kiam](https://github.com/uswitch/kiam). Modify the manifests [here](deploy) accordingly, then run:
19+
Run:
2220

2321
```bash
24-
$ kubectl apply -f config/crd/bases/ # install Custom Resource Definition (CRD) for EIP Custom Resource
25-
$ kubectl apply -f deploy/ # install the operator
22+
$ helm install --namespace kube-system --set aws.region=us-east-1 oci://ghcr.io/goto-opensource/k8s-aws-operator --version v1.0.0 # adjust version
2623
```
2724

25+
If you want to use [IAM roles for service accounts](https://docs.aws.amazon.com/eks/latest/userguide/iam-roles-for-service-accounts.html), add the required trust relationship with your cluster to the IAM role and add the corresponding annotation on the service account (e.g. by setting the Helm value `serviceAccount.annotations."eks.amazonaws.com/role-arn"` accordingly).
26+
2827
## Usage
2928

3029
### EIPs

charts/k8s-aws-operator/Chart.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
apiVersion: v1
2+
type: application
3+
name: k8s-aws-operator
4+
version: 0.0.0-placeholder
5+
appVersion: v0.0.0-placeholder
6+
description: Operator for managing ENIs and EIPs in AWS from within Kubernetes
7+
home: https://github.com/goto-opensource/k8s-aws-operator
8+
maintainers:
9+
- name: Alfred Krohmer
10+
11+
url: https://github.com/alfredkrohmer

0 commit comments

Comments
 (0)