Skip to content
This repository was archived by the owner on Apr 24, 2024. It is now read-only.

Commit 51c66c6

Browse files
committed
wip
Signed-off-by: Andy Goldstein <andy.goldstein@redhat.com>
1 parent 5f14377 commit 51c66c6

File tree

4 files changed

+32
-24
lines changed

4 files changed

+32
-24
lines changed

Makefile

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ manifests: controller-gen ## Generate WebhookConfiguration, ClusterRole and Cust
4747
$(CONTROLLER_GEN) rbac:roleName=manager-role crd webhook paths="./..." output:crd:artifacts:config=config/crd/bases
4848

4949
.PHONY: apiresourceschemas
50-
apiresourceschemas: kustomize
50+
apiresourceschemas: kustomize ## Convert CRDs from config/crds to APIResourceSchemas. Specify APIEXPORT_PREFIX as needed.
5151
$(KUSTOMIZE) build config/crd | kubectl kcp crd snapshot -f - --prefix $(APIEXPORT_PREFIX) > config/kcp/$(APIEXPORT_PREFIX).apiresourceschemas.yaml
5252

5353
.PHONY: generate
@@ -94,20 +94,20 @@ ifndef ignore-not-found
9494
endif
9595

9696
.PHONY: install
97-
install: manifests kustomize ## Install APIResourceSchemas and APIExport into the K8s cluster specified in ~/.kube/config.
98-
kubectl apply -f config/kcp
97+
install: manifests kustomize ## Install APIResourceSchemas and APIExport into kcp (using $KUBECONFIG or ~/.kube/config).
98+
kustomize build config/kcp | kubectl apply -f -
9999

100100
.PHONY: uninstall
101-
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.
102-
kubectl delete --ignore-not-found=$(ignore-not-found) -f config/kcp
101+
uninstall: manifests kustomize ## Uninstall APIResourceSchemas and APIExport from kcp (using $KUBECONFIG or ~/.kube/config). Call with ignore-not-found=true to ignore resource not found errors during deletion.
102+
kustomize build config/kcp | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
103103

104104
.PHONY: deploy
105-
deploy: manifests kustomize ## Deploy controller to the K8s cluster specified in ~/.kube/config.
105+
deploy: manifests kustomize ## Deploy controller
106106
cd config/manager && $(KUSTOMIZE) edit set image controller=${IMG}
107107
$(KUSTOMIZE) build config/default | kubectl apply -f -
108108

109109
.PHONY: undeploy
110-
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.
110+
undeploy: ## Undeploy controller. Call with ignore-not-found=true to ignore resource not found errors during deletion.
111111
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -
112112

113113
##@ Build Dependencies

README.md

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,55 +5,55 @@ An example project that is multi-cluster aware and works with [kcp](https://gith
55
This repository contains an example project that works with APIExports and multiple kcp workspaces. It demonstrates
66
two reconcilers:
77

8-
1.
8+
1. ConfigMap
9+
1. Get a ConfigMap for the key from the queue, from the correct logical cluster
10+
2. If the ConfigMap has labels["name"], set labels["response"] = "hello-$name" and save the changes
11+
3. List all ConfigMaps in the logical cluster and log each one's namespace and name
12+
4. If the ConfigMap from step 1
13+
2. Widget
914

1015
## Getting Started
1116

1217

13-
### Running on the cluster
14-
1. Install Instances of Custom Resources:
18+
### Running on kcp
1519

16-
```sh
17-
kubectl apply -f config/samples/
18-
```
19-
20-
2. Build and push your image to the location specified by `IMG`:
20+
1. Build and push your image to the location specified by `IMG`:
2121

2222
```sh
2323
make docker-build docker-push IMG=<some-registry>/controller-runtime-example:tag
2424
```
2525

26-
3. Deploy the controller to the cluster with the image specified by `IMG`:
26+
1. Deploy the controller to kcp with the image specified by `IMG`:
2727

2828
```sh
2929
make deploy IMG=<some-registry>/controller-runtime-example:tag
3030
```
3131

32-
### Uninstall CRDs
33-
To delete the CRDs from the cluster:
32+
### Uninstall resources
33+
To delete the resources from kcp:
3434

3535
```sh
3636
make uninstall
3737
```
3838

3939
### Undeploy controller
40-
UnDeploy the controller to the cluster:
40+
Undeploy the controller from kcp:
4141

4242
```sh
4343
make undeploy
4444
```
4545

4646
## Contributing
47-
// TODO(user): Add detailed information on how you would like others to contribute to this project
47+
See [CONTRIBUTING.md](CONTRIBUTING.md)
4848

4949
### How it works
5050
This project aims to follow the Kubernetes [Operator pattern](https://kubernetes.io/docs/concepts/extend-kubernetes/operator/)
5151

5252
It uses [Controllers](https://kubernetes.io/docs/concepts/architecture/controller/)
53-
which provides a reconcile function responsible for synchronizing resources untile the desired state is reached on the cluster
53+
which provides a reconcile function responsible for synchronizing resources until the desired state is reached.
5454

5555
### Test It Out
56-
1. Install the CRDs into the cluster:
56+
1. Install the required resources into kcp:
5757

5858
```sh
5959
make install
@@ -68,7 +68,7 @@ make run
6868
**NOTE:** You can also run this in one step by running: `make install run`
6969

7070
### Modifying the API definitions
71-
If you are editing the API definitions, generate the manifests such as CRs or CRDs using:
71+
If you are editing the API definitions, regenerate the manifests using:
7272

7373
```sh
7474
make manifests

config/kcp/kustomizeconfig.yaml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# This file is for teaching kustomize how to substitute name and namespace reference in CRD
21
nameReference:
32
- kind: APIResourceSchema
43
fieldSpecs:

main.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,16 @@ func main() {
8686

8787
restConfig := ctrl.GetConfigOrDie()
8888

89+
apiExportName := os.Args[1]
90+
setupLog = setupLog.WithValues("api-export", apiExportName)
91+
92+
setupLog.Info("Looking up virtual workspace URL")
8993
cfg, err := restConfigForAPIExport(ctx, restConfig, os.Args[1])
94+
if err != nil {
95+
setupLog.Error(err, "error looking up virtual workspace URL")
96+
}
97+
98+
setupLog.Info("Using virtual workspace URL", "url", cfg.Host)
9099

91100
mgr, err := kcp.NewClusterAwareManager(cfg, ctrl.Options{
92101
Scheme: scheme,

0 commit comments

Comments
 (0)