This repository has been archived by the owner on Jul 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from katulu-io/GerardoGR/local-kind-cluster
Local kind cluster setup
- Loading branch information
Showing
17 changed files
with
403 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# KUBECONFIG | ||
/local.fl-suite.kubeconfig.yaml | ||
/.local.fl-suite-internal.kubeconfig.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
DOCKER_NETWORK_NAME = kind | ||
|
||
-include ../.devcontainer/targets.mk | ||
|
||
dependencies lint test build dist push: | ||
@echo "$@ not implemented" | ||
.PHONY: dependencies lint test build dist push | ||
|
||
local-registry: | ||
docker network create kind || true | ||
docker run -d --name registry --restart=always -p 5000:5000 --net=kind registry:2 | ||
.PHONY: local-registry | ||
|
||
provision: | ||
@./provision.sh | ||
.PHONY: provision | ||
|
||
teardown: | ||
@./teardown.sh | ||
.PHONY: teardown |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
# Local kubernetes cluster | ||
|
||
## Requirements | ||
|
||
* [kubectl](https://kubernetes.io/docs/tasks/tools/#kubectl). | ||
* [kustomize](https://kubectl.docs.kubernetes.io/installation/kustomize/). | ||
* [kind](https://kind.sigs.k8s.io/docs/user/quick-start/#installation). | ||
|
||
> 🌻 Add `devcontainer-` to any of the make targets to use a container image with the requirements already pre-installed | ||
## Deploy | ||
|
||
To deploy a local kubernetes cluster we will use kind (Kubernetes In Docker). | ||
|
||
### 1. Setup a local container registry | ||
|
||
The kind cluster uses a local registry to host the fl-suite container images. To deploy this run: | ||
|
||
```shell | ||
make local-registry | ||
``` | ||
|
||
|
||
### 2. Push the fl-suite images to the local container registry | ||
|
||
Build, dist and push the fl-suite's container images. This needs to be done at the root of the project: | ||
|
||
On Linux (with all the tools to build all the components of the fl-suite): | ||
|
||
``` | ||
cd /path/to/katulu-io/fl-suite/ | ||
export MAKEVAR_REGISTRY=localhost:5000 | ||
make build dist push | ||
``` | ||
|
||
On any other platform: | ||
|
||
``` | ||
cd /path/to/katulu-io/fl-suite/ | ||
export MAKEVAR_REGISTRY=localhost:5000 | ||
make devcontainer-build devcontainer-dist push | ||
``` | ||
|
||
### 3. Provision the kind cluster | ||
|
||
```shell | ||
make provision | ||
``` | ||
|
||
That step will show some errors like: | ||
|
||
``` | ||
Error from server (NotFound): error when creating "STDIN": namespaces "katulu-fl" not found | ||
``` | ||
|
||
This and other CRD related errors are expected. The namespace "katulu-fl" gets created once a Kubeflow Profile is reconciled in kubernetes which might take some time. The other CRD errors (e.g cert-manager's Certificates CRDs) have the same cause. The `provision` target will take care to retry this as many times as it needs and normally this takes around ~20 mins but depends on the local resources like CPU, Network, etc. | ||
|
||
> 🌻 The same make-target can be used to update the cluster with the latest kustomize changes | ||
A kubeconfig file is generated which can be used to configure `kubectl` and access the kind cluster: | ||
|
||
```shell | ||
export KUBECONFIG=local.fl-suite.kubeconfig.yaml | ||
kubectl get nodes | ||
NAME STATUS ROLES AGE VERSION | ||
local.fl-suite-control-plane Ready control-plane,master 5m00s v1.21.10 | ||
``` | ||
|
||
### 4. Wait for all the pods to be ready | ||
|
||
```shell | ||
export KUBECONFIG=local.fl-suite.kubeconfig.yaml | ||
kubectl get pods -n cert-manager | ||
kubectl get pods -n istio-system | ||
kubectl get pods -n auth | ||
kubectl get pods -n knative-eventing | ||
kubectl get pods -n knative-serving | ||
kubectl get pods -n kubeflow | ||
kubectl get pods -n katulu-fl | ||
kubectl get pods -n spire | ||
kubectl get pods -n container-registry | ||
``` | ||
|
||
### 5. Login to the fl-suite central dashboard | ||
|
||
Once all pods are ready, you can access the fl-suite via: | ||
|
||
On Linux: http://localhost | ||
On MacOS: http://docker.for.mac.localhost | ||
|
||
The credentials are: | ||
|
||
``` | ||
Username: user@example.com | ||
Password: 12341234 | ||
``` | ||
|
||
## Teardown | ||
|
||
```shell | ||
make teardown | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
--- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
name: local.fl-suite | ||
containerdConfigPatches: | ||
- |- | ||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:5000"] | ||
endpoint = ["http://registry:5000"] | ||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."container-registry.container-registry:5000"] | ||
endpoint = ["http://local.fl-suite-control-plane:30080"] | ||
nodes: | ||
- role: control-plane | ||
# Using kubernetes version 1.21 to avoid "no matches for kind "CustomResourceDefinition"" error (related issue: https://github.com/kubeflow/manifests/issues/2028) | ||
image: kindest/node:v1.21.10@sha256:84709f09756ba4f863769bdcabe5edafc2ada72d3c8c44d6515fc581b66b029c | ||
extraPortMappings: | ||
- containerPort: 30080 | ||
hostPort: 80 | ||
- containerPort: 30443 | ||
hostPort: 443 | ||
# TODO: Remove this extra mount. The FLOperator pods expect a /dataset directory in the kubernetes node. To | ||
# force-create one we let kind do it | ||
extraMounts: | ||
- hostPath: dataset/ | ||
containerPath: /dataset | ||
readOnly: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
apiVersion: security.istio.io/v1beta1 | ||
kind: AuthorizationPolicy | ||
metadata: | ||
name: allow-fl-operator-access | ||
namespace: katulu-fl | ||
spec: | ||
rules: | ||
- from: | ||
- source: | ||
principals: ["cluster.local/ns/fl-operator-system/sa/fl-operator-controller-manager"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
{ | ||
"auths":{ | ||
"container-registry.container-registry:5000": { | ||
"auth":"cmVnaXN0cnk6cmVnaXN0cnk=" | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
agent { | ||
data_dir = "/run/spire" | ||
log_level = "DEBUG" | ||
server_address = "spire-server" | ||
server_port = "8081" | ||
socket_path = "/run/spire/sockets/agent.sock" | ||
trust_bundle_path = "/run/spire/bundle/bundle.crt" | ||
trust_domain = "katulu.io" | ||
} | ||
|
||
plugins { | ||
NodeAttestor "k8s_psat" { | ||
plugin_data { | ||
cluster = "local-k8s" | ||
} | ||
} | ||
|
||
KeyManager "memory" { | ||
plugin_data { | ||
} | ||
} | ||
|
||
WorkloadAttestor "k8s" { | ||
plugin_data { | ||
skip_kubelet_verification = true | ||
} | ||
} | ||
|
||
WorkloadAttestor "unix" { | ||
plugin_data { | ||
} | ||
} | ||
} |
Oops, something went wrong.