Skip to content

Commit 43af4d4

Browse files
shorten cluster-api-provider-linode to capl, add release process (#124)
* shorten cluster-api-provider-linode to capl, add release process * update docs for name shortening, add release page
1 parent 2da526a commit 43af4d4

File tree

18 files changed

+278
-81
lines changed

18 files changed

+278
-81
lines changed

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: Release
2+
on:
3+
push:
4+
tags:
5+
- "*"
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
with:
13+
fetch-depth: 0
14+
- name: Create Release Artifacts
15+
run: make release
16+
env:
17+
RELEASE_TAG: ${{ github.ref_name }}
18+
- name: Upload Release Artifacts
19+
uses: softprops/action-gh-release@v1
20+
with:
21+
files: |
22+
./release
23+
- name: Docker Meta
24+
id: meta
25+
uses: docker/metadata-action@v5
26+
with:
27+
images: |
28+
linode/cluster-api-provider-linode
29+
tags: |
30+
type=raw,value=latest,enable=${{ github.ref == format('refs/heads/{0}', 'main') }}
31+
type=semver,pattern={{raw}},value=${{ github.ref_name }}
32+
- name: Login to Docker Hub
33+
uses: docker/login-action@v3
34+
with:
35+
username: ${{ secrets.DOCKER_USERNAME }}
36+
password: ${{ secrets.DOCKER_PASSWORD }}
37+
- name: Build and Push to Docker Hub
38+
uses: docker/build-push-action@v5
39+
with:
40+
context: .
41+
push: true
42+
tags: ${{ steps.meta.outputs.tags }}
43+
labels: ${{ steps.meta.outputs.labels }}

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,3 +6,4 @@ cover.out
66
kubeconfig*
77
.devbox/*
88
docs/book
9+
release/*

Makefile

Lines changed: 84 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1-
2-
# Image URL to use all building/pushing image targets
3-
IMG ?= controller:latest
1+
REGISTRY ?= docker.io/linode
2+
IMAGE_NAME ?= cluster-api-provider-linode
3+
CONTROLLER_IMAGE ?= $(REGISTRY)/$(IMAGE_NAME)
4+
TAG ?= dev
45
# ENVTEST_K8S_VERSION refers to the version of kubebuilder assets to be downloaded by envtest binary.
56
ENVTEST_K8S_VERSION = 1.28.0
67
OS=$(shell uname -s | tr '[:upper:]' '[:lower:]')
@@ -47,11 +48,22 @@ all: build
4748
# More info on the awk command:
4849
# http://linuxcommand.org/lc3_adv_awk.php
4950

51+
52+
## --------------------------------------
53+
## Help
54+
## --------------------------------------
55+
56+
##@ Help:
57+
5058
.PHONY: help
5159
help: ## Display this help.
5260
@awk 'BEGIN {FS = ":.*##"; printf "\nUsage:\n make \033[36m<target>\033[0m\n"} /^[a-zA-Z_0-9-]+:.*?##/ { printf " \033[36m%-15s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' $(MAKEFILE_LIST)
5361

54-
##@ Development
62+
## --------------------------------------
63+
## Generate
64+
## --------------------------------------
65+
66+
##@ Generate:
5567

5668
.PHONY: manifests
5769
manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and CustomResourceDefinition objects.
@@ -61,6 +73,12 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
6173
generate: controller-gen ## Generate code containing DeepCopy, DeepCopyInto, and DeepCopyObject method implementations.
6274
$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."
6375

76+
## --------------------------------------
77+
## Development
78+
## --------------------------------------
79+
80+
##@ Development:
81+
6482
.PHONY: fmt
6583
fmt: ## Run go fmt against code.
6684
go fmt ./...
@@ -85,6 +103,12 @@ nilcheck: nilaway ## Run nil check against code.
85103
vulncheck: govulncheck ## Run vulnerability check against code.
86104
govulncheck ./...
87105

106+
## --------------------------------------
107+
## Testing
108+
## --------------------------------------
109+
110+
##@ Testing:
111+
88112
.PHONY: test
89113
test: manifests generate fmt vet envtest ## Run tests.
90114
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test -race -timeout 60s ./... -coverprofile cover.out
@@ -101,7 +125,11 @@ _e2etest-infra: kind ctlptl tilt kuttl kustomize clusterctl envsubst
101125
_e2etest: manifests generate envsubst _e2etest-infra
102126
ROOT_DIR="$(PWD)" $(KUTTL) test --config e2e/kuttl-config.yaml
103127

104-
##@ Build
128+
## --------------------------------------
129+
## Build
130+
## --------------------------------------
131+
132+
##@ Build:
105133

106134
.PHONY: build
107135
build: manifests generate fmt vet ## Build manager binary.
@@ -116,11 +144,11 @@ run: manifests generate fmt vet ## Run a controller from your host.
116144
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
117145
.PHONY: docker-build
118146
docker-build: ## Build docker image with the manager.
119-
$(CONTAINER_TOOL) build $(BUILD_ARGS) -t ${IMG} .
147+
$(CONTAINER_TOOL) build $(BUILD_ARGS) . -t $(CONTROLLER_IMAGE):$(TAG)
120148

121149
.PHONY: docker-push
122150
docker-push: ## Push docker image with the manager.
123-
$(CONTAINER_TOOL) push ${IMG}
151+
$(CONTAINER_TOOL) push $(CONTROLLER_IMAGE):$(TAG)
124152

125153
# PLATFORMS defines the target platforms for the manager image be built to provide support to multiple
126154
# architectures. (i.e. make docker-buildx IMG=myregistry/mypoperator:0.0.1). To use this option you need to:
@@ -135,40 +163,63 @@ docker-buildx: ## Build and push docker image for the manager for cross-platform
135163
sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross
136164
- $(CONTAINER_TOOL) buildx create --name project-v3-builder
137165
$(CONTAINER_TOOL) buildx use project-v3-builder
138-
- $(CONTAINER_TOOL) buildx build $(BUILD_ARGS) --push --platform=$(PLATFORMS) --tag ${IMG} -f Dockerfile.cross .
166+
- $(CONTAINER_TOOL) buildx build $(BUILD_ARGS) --push --platform=$(PLATFORMS) --tag $(CONTROLLER_IMAGE):$(TAG) -f Dockerfile.cross .
139167
- $(CONTAINER_TOOL) buildx rm project-v3-builder
140168
rm Dockerfile.cross
141169

142-
##@ Deployment
170+
## --------------------------------------
171+
## Deployment
172+
## --------------------------------------
173+
174+
##@ Deployment:
143175

144176
ifndef ignore-not-found
145177
ignore-not-found = false
146178
endif
147179

148-
.PHONY: install
149-
install: manifests kustomize ## Install CRDs into the K8s cluster specified in ~/.kube/config.
150-
$(KUSTOMIZE) build config/crd | $(KUBECTL) apply -f -
151-
152-
.PHONY: uninstall
153-
uninstall: manifests kustomize ## Uninstall CRDs from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
154-
$(KUSTOMIZE) build config/crd | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
155-
156-
.PHONY: deploy
157-
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
158-
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
159-
$(KUSTOMIZE) build config/default | $(KUBECTL) apply -f -
160-
161-
.PHONY: undeploy
162-
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
163-
$(KUSTOMIZE) build config/default | $(KUBECTL) delete --ignore-not-found=$(ignore-not-found) -f -
164-
165180
.PHONY: tilt-cluster
166181
tilt-cluster: ctlptl tilt kind clusterctl
167182
@echo -n "LINODE_TOKEN=$(LINODE_TOKEN)" > config/default/.env.linode
168183
$(CTLPTL) apply -f .tilt/ctlptl-config.yaml
169184
$(TILT) up --stream
170185

171-
##@ Build Dependencies
186+
## --------------------------------------
187+
## Release
188+
## --------------------------------------
189+
190+
##@ Release:
191+
192+
RELEASE_DIR ?= release
193+
RELEASE_TAG ?= $(shell git describe --abbrev=0 2>/dev/null)
194+
195+
.PHONY: set-manifest-image
196+
set-manifest-image: ## Update kustomize image patch file for default resource.
197+
sed -i'' -e 's@image: .*@image: '"${MANIFEST_IMG}:${MANIFEST_TAG}"'@' ./config/default/manager_image_patch.yaml
198+
199+
.PHONY: release
200+
release: $(KUSTOMIZE)
201+
rm -rf $(RELEASE_DIR)
202+
mkdir -p $(RELEASE_DIR)/
203+
$(MAKE) set-manifest-image MANIFEST_IMG=$(REGISTRY)/$(IMAGE_NAME) MANIFEST_TAG=$(RELEASE_TAG)
204+
$(KUSTOMIZE) build config/default > $(RELEASE_DIR)/infrastructure-components.yaml
205+
cp templates/cluster-template* $(RELEASE_DIR)/
206+
cp metadata.yaml $(RELEASE_DIR)/metadata.yaml
207+
208+
## --------------------------------------
209+
## Cleanup
210+
## --------------------------------------
211+
212+
##@ Cleanup:
213+
214+
.PHONY: clean
215+
clean:
216+
rm -rf $(LOCALBIN)
217+
218+
## --------------------------------------
219+
## Build Dependencies
220+
## --------------------------------------
221+
222+
##@ Build Dependencies:
172223

173224
## Location to install dependencies to
174225

@@ -188,7 +239,12 @@ export PATH := $(CACHE_BIN):$(PATH)
188239
$(LOCALBIN):
189240
mkdir -p $(LOCALBIN)
190241

191-
## Tool Binaries
242+
## --------------------------------------
243+
## Tooling Binaries
244+
## --------------------------------------
245+
246+
##@ Tooling Binaries:
247+
192248
KUBECTL ?= kubectl
193249
KUSTOMIZE ?= $(LOCALBIN)/kustomize
194250
CTLPTL ?= $(LOCALBIN)/ctlptl
@@ -290,7 +346,3 @@ $(NILAWAY): $(LOCALBIN)
290346
govulncheck: $(GOVULNC) ## Download govulncheck locally if necessary.
291347
$(GOVULNC): $(LOCALBIN)
292348
GOBIN=$(LOCALBIN) go install golang.org/x/vuln/cmd/govulncheck@$(GOVULNC_VERSION)
293-
294-
.PHONY: clean
295-
clean:
296-
rm -rf $(LOCALBIN)

Tiltfile

Lines changed: 24 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,42 @@
11
load("ext://k8s_attach", "k8s_attach")
22

3-
docker_build("controller", ".", only=("Dockerfile", "Makefile", "vendor","go.mod", "go.sum", "./api", "./cloud","./cmd", "./controller", "./util", "./version"), build_args={'VERSION': os.getenv("VERSION","")})
3+
docker_build(
4+
"docker.io/linode/cluster-api-provider-linode",
5+
context = ".",
6+
only=("Dockerfile", "Makefile", "vendor","go.mod", "go.sum", "./api", "./cloud","./cmd", "./controller", "./util", "./version"),
7+
build_args={'VERSION': os.getenv("VERSION","")},
8+
)
49

510
local_resource(
611
'capi-controller-manager',
712
cmd='EXP_CLUSTER_RESOURCE_SET=true clusterctl init --addon helm',
813
)
914

10-
k8s_yaml(kustomize('config/default'))
11-
12-
# get generated secret name so we can categorize it
13-
token_secret_name = str(local('kustomize build config/default | grep -m1 "name: cluster-api-provider-linode-token-"', quiet=True, echo_off=True)).split()[1]
15+
templated_yaml = local(
16+
'kustomize build config/default | envsubst',
17+
env={'LINODE_TOKEN': os.getenv('LINODE_TOKEN')},
18+
quiet=True,
19+
echo_off=True
20+
)
21+
k8s_yaml(templated_yaml)
1422

1523
k8s_resource(
16-
workload="cluster-api-provider-linode-controller-manager",
24+
workload="capl-controller-manager",
1725
objects=[
18-
"cluster-api-provider-linode-system:namespace",
26+
"capl-system:namespace",
1927
"linodeclusters.infrastructure.cluster.x-k8s.io:customresourcedefinition",
2028
"linodemachines.infrastructure.cluster.x-k8s.io:customresourcedefinition",
2129
"linodeclustertemplates.infrastructure.cluster.x-k8s.io:customresourcedefinition",
2230
"linodemachinetemplates.infrastructure.cluster.x-k8s.io:customresourcedefinition",
2331
"linodevpcs.infrastructure.cluster.x-k8s.io:customresourcedefinition",
24-
"cluster-api-provider-linode-controller-manager:serviceaccount",
25-
"cluster-api-provider-linode-leader-election-role:role",
26-
"cluster-api-provider-linode-manager-role:clusterrole",
27-
"cluster-api-provider-linode-metrics-reader:clusterrole",
28-
"cluster-api-provider-linode-proxy-role:clusterrole",
29-
"cluster-api-provider-linode-leader-election-rolebinding:rolebinding",
30-
"cluster-api-provider-linode-manager-rolebinding:clusterrolebinding",
31-
"cluster-api-provider-linode-proxy-rolebinding:clusterrolebinding",
32-
"%s:secret" % token_secret_name
32+
"capl-controller-manager:serviceaccount",
33+
"capl-leader-election-role:role",
34+
"capl-manager-role:clusterrole",
35+
"capl-metrics-reader:clusterrole",
36+
"capl-proxy-role:clusterrole",
37+
"capl-leader-election-rolebinding:rolebinding",
38+
"capl-manager-rolebinding:clusterrolebinding",
39+
"capl-proxy-rolebinding:clusterrolebinding",
40+
"capl-manager-credentials:secret",
3341
]
3442
)

config/crd/kustomization.yaml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
# common labels for CRD resources as required by
22
# https://cluster-api.sigs.k8s.io/developer/providers/contracts.html#api-version-labels
3-
commonLabels:
4-
cluster.x-k8s.io/v1beta1: v1alpha1
3+
labels:
4+
- pairs:
5+
cluster.x-k8s.io/v1beta1: v1alpha1
56

67
# This kustomization.yaml is not intended to be run by itself,
78
# since it depends on service name and namespace that are out of this kustomize package.

config/default/kustomization.yaml

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,18 @@
11
# Adds namespace to all resources.
2-
namespace: cluster-api-provider-linode-system
2+
namespace: capl-system
33

44
# Value of this field is prepended to the
55
# names of all resources, e.g. a deployment named
66
# "wordpress" becomes "alices-wordpress".
77
# Note that it should also match with the prefix (text before '-') of the namespace
88
# field above.
9-
namePrefix: cluster-api-provider-linode-
10-
11-
# Labels to add to all resources and selectors.
12-
#labels:
13-
#- includeSelectors: true
14-
# pairs:
15-
# someName: someValue
9+
namePrefix: capl-
1610

1711
resources:
1812
- ../crd
1913
- ../rbac
2014
- ../manager
15+
- linode-token-secret.yaml
2116
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
2217
# crd/kustomization.yaml
2318
#- ../webhook
@@ -26,18 +21,10 @@ resources:
2621
# [PROMETHEUS] To enable prometheus monitor, uncomment all sections with 'PROMETHEUS'.
2722
#- ../prometheus
2823

29-
secretGenerator:
30-
- name: token
31-
envs:
32-
- .env.linode
33-
34-
patchesStrategicMerge:
35-
# Protect the /metrics endpoint by putting it behind auth.
36-
# If you want your controller-manager to expose the /metrics
37-
# endpoint w/o any authn/z, please comment the following line.
38-
- manager_auth_proxy_patch.yaml
39-
40-
24+
patches:
25+
- path: manager_auth_proxy_patch.yaml
26+
- path: manager_image_patch.yaml
27+
- path: manager_credentials_patch.yaml
4128

4229
# [WEBHOOK] To enable webhook, uncomment all the sections with [WEBHOOK] prefix including the one in
4330
# crd/kustomization.yaml
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
apiVersion: v1
3+
kind: Secret
4+
metadata:
5+
name: manager-credentials
6+
stringData:
7+
apiToken: ${LINODE_TOKEN}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
---
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: controller-manager
6+
namespace: system
7+
spec:
8+
template:
9+
spec:
10+
containers:
11+
- name: manager
12+
env:
13+
- name: LINODE_TOKEN
14+
valueFrom:
15+
secretKeyRef:
16+
key: apiToken
17+
name: capl-manager-credentials

0 commit comments

Comments
 (0)