Skip to content

Commit 8d20ae8

Browse files
committed
fix #5
1 parent fe0c054 commit 8d20ae8

13 files changed

+190
-221
lines changed

.gitignore

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ Dockerfile.cross
2525
*.swo
2626
*~
2727

28-
2928
*_test.go
3029

31-
#
32-
config/samples/secret.yaml
30+
# release
31+
out

Makefile

Lines changed: 53 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ else
1111
GOBIN=$(shell go env GOBIN)
1212
endif
1313

14+
GOARCH := $(shell go env GOARCH)
15+
GOOS := $(shell go env GOOS)
16+
1417
# Setting SHELL to bash allows bash commands to be executed by recipes.
1518
# Options are set to exit when a recipe line exits non-zero or a piped command fails.
1619
SHELL = /usr/bin/env bash -o pipefail
@@ -58,6 +61,16 @@ vet: ## Run go vet against code.
5861
test: manifests generate fmt vet envtest ## Run tests.
5962
KUBEBUILDER_ASSETS="$(shell $(ENVTEST) use $(ENVTEST_K8S_VERSION) --bin-dir $(LOCALBIN) -p path)" go test ./... -coverprofile cover.out
6063

64+
CLUSTER_NAME := cappx-test
65+
66+
.PHONY: create-workload-cluster
67+
create-workload-cluster: $(KUSTOMIZE) $(ENVSUBST) $(KUBECTL)
68+
export CLUSTER_NAME=$(CLUSTER_NAME) && $(KUSTOMIZE) build templates | $(ENVSUBST) | $(KUBECTL) apply -f -
69+
70+
.PHONY: delete-workload-cluster
71+
delete-workload-cluster: $(KUBECTL)
72+
$(KUBECTL) delete cluster $(CLUSTER_NAME)
73+
6174
##@ Build
6275

6376
.PHONY: build
@@ -72,7 +85,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
7285
# (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it.
7386
# More info: https://docs.docker.com/develop/develop-images/build_enhancements/
7487
.PHONY: docker-build
75-
docker-build: test ## Build docker image with the manager.
88+
docker-build: # test ## Build docker image with the manager.
7689
docker build -t ${IMG} .
7790

7891
.PHONY: docker-push
@@ -119,6 +132,30 @@ deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in
119132
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.
120133
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
121134

135+
##@ Release
136+
137+
## Location to output for release
138+
RELEASE_DIR := out
139+
$(RELEASE_DIR):
140+
mkdir -p $(RELEASE_DIR)
141+
142+
# RELEASE_TAG := $(shell git describe --abbrev=0 2>/dev/null)
143+
144+
# .PHONY: release
145+
146+
.PHONY: release-manifests
147+
release-manifests: $(KUSTOMIZE) $(RELEASE_DIR) ## Builds the manifests to publish with a release
148+
$(KUSTOMIZE) build config/default > $(RELEASE_DIR)/infrastructure-components.yaml
149+
150+
.PHONY: release-metadata
151+
release-metadata: $(RELEASE_DIR)
152+
cp metadata.yaml $(RELEASE_DIR)/metadata.yaml
153+
154+
.PHONY: release-templates
155+
release-templates: $(RELEASE_DIR)
156+
cp templates/cluster-template* $(RELEASE_DIR)/
157+
158+
122159
##@ Build Dependencies
123160

124161
## Location to install dependencies to
@@ -130,10 +167,14 @@ $(LOCALBIN):
130167
KUSTOMIZE ?= $(LOCALBIN)/kustomize
131168
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
132169
ENVTEST ?= $(LOCALBIN)/setup-envtest
170+
ENVSUBST ?= $(LOCALBIN)/envsubst
171+
KUBECTL ?= $(LOCALBIN)/kubectl
133172

134173
## Tool Versions
135174
KUSTOMIZE_VERSION ?= v5.0.0
136175
CONTROLLER_TOOLS_VERSION ?= v0.11.3
176+
ENVSUBST_VER ?= v1.4.2
177+
KUBECTL_VER := v1.25.10
137178

138179
KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
139180
.PHONY: kustomize
@@ -155,3 +196,14 @@ $(CONTROLLER_GEN): $(LOCALBIN)
155196
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
156197
$(ENVTEST): $(LOCALBIN)
157198
test -s $(LOCALBIN)/setup-envtest || GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest
199+
200+
.PHONY: envsubst
201+
envsubst: $(ENVSUBST)
202+
$(ENVSUBST): $(LOCALBIN)
203+
GOBIN=$(LOCALBIN) go install github.com/a8m/envsubst/cmd/envsubst@$(ENVSUBST_VER)
204+
205+
.PHONY: kubectl
206+
kubectl: $(KUBECTL)
207+
$(KUBECTL): $(LOCALBIN)
208+
curl --retry 3 -fsL https://dl.k8s.io/release/$(KUBECTL_VER)/bin/$(GOOS)/$(GOARCH)/kubectl -o $(LOCALBIN)/kubectl
209+
chmod +x $(KUBECTL)

README.md

Lines changed: 23 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -25,49 +25,36 @@ make deploy
2525

2626
2. Create your first workload cluster
2727
```sh
28-
# cluster & infra cluster
29-
kubectl apply -f config/samples/cluster.yaml
30-
kubectl apply -f config/samples/infrastructure_v1beta1_proxmoxcluster.yaml
28+
# export env variables
29+
export CONTROLPLANE_HOST=X.X.X.X
30+
export PROXMOX_URL=X.X.X.X:8006
31+
export GATEWAY_ADDRESS=X.X.X.X
32+
export NAMESERVER_ADDRESS=X.X.X.X
33+
export PROXMOX_PASSWORD_BASE64=$(echo -n <password> | base64)
34+
export PROXMOX_USER_BASE64=$(echo -n <user@pam> | base64)
35+
export NODE_URL_BASE64=$(echo -n <node.ssh.url:22> | base64)
36+
export NODE_USER_BASE64=$(echo -n <node-ssh-user> | base64)
37+
export NODE_PASSWORD_BASE64=$(echo -n <node-ssh-password> | base64)
38+
39+
make create-workload-cluster
40+
```
3141

32-
# controlplane
33-
kubectl apply -f config/samples/controlplane.yaml
42+
3. Access your first workload cluster !!
3443

35-
# machine & bootstrap & infra machine
36-
kubectl apply -f config/samples/machine.yaml
37-
kubectl apply -f config/samples/bootstrap.yaml
38-
kubectl apply -f config/samples/infrastructure_v1beta1_proxmoxcluster.yaml
44+
Usually it takes 2~5 mins to complete bootstrap the nodes.
45+
```sh
46+
# get workload cluster's kubeconfig
47+
clusterctl get kubeconfig cappx-test > kubeconfig.yaml
3948

40-
# proxmox configs
41-
kubetl apply -f <your-proxmox-config-secret>.yaml
49+
# get node command for workload cluster
50+
kubectl --kubeconfig=kubeconfig.yaml get node
4251
```
4352

44-
You need to provide your proxmox information through secret.
45-
```yaml
46-
# <your-proxmox-config-secret>.yaml
47-
apiVersion: v1
48-
data:
49-
# for proxmox API
50-
PROXMOX_PASSWORD: "<base 64>"
51-
PROXMOX_USER: "<base 64>"
52-
# for ssh into the node to bootstrapping VMs
53-
## * current CAPP is compatible with only single node proxmox cluster
54-
NODE_URL: "<base 64>"
55-
NODE_USER: "<base 64>"
56-
NODE_PASSWORD: "<base 64>"
57-
kind: Secret
58-
metadata:
59-
name: proxmoxcluster-sample
60-
type: Opaque
53+
4. Tear down your workload cluster
54+
```sh
55+
make delete-workload-cluster
6156
```
6257

63-
3. Check your Cluster & Machines !!
64-
65-
Once CAPP reconciled your `ProxmoxCluster`/`ProxmoxMachine`, you can see `READY=true` for `ProxmoxCluster` and `STATUS=running` for `ProxmoxMachine`.
66-
67-
![kubectl-get-proxmox-cluster](./logos/k-get-proxmoxcluster.PNG)
68-
69-
![kubectl-get-proxmox-machine](./logos/k-get-proxmoxmachine.PNG)
70-
7158
## Fetures
7259

7360
- No need to prepare vm templates. You can specify any vm image in `ProxmoxMachine.Spec.Image`.

config/samples/bootstrap.yaml

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

config/samples/cluster.yaml

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

config/samples/controlplane.yaml

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

config/samples/infrastructure_v1beta1_proxmoxcluster.yaml

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

config/samples/infrastructure_v1beta1_proxmoxmachine.yaml

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

config/samples/infrastructure_v1beta1_proxmoxmachinetemplate.yaml

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

config/samples/kustomization.yaml

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

0 commit comments

Comments
 (0)