From 4d52dda0afdfa4b38ceb96e15e790abeff21e60e Mon Sep 17 00:00:00 2001 From: Daniel Flanagan Date: Tue, 5 Jul 2022 15:53:37 -0500 Subject: [PATCH] Cleanup and add echoserver --- home/manifests/echoserver/deployment.yaml | 24 +++++++++++++++++++ home/manifests/echoserver/kustomization.yaml | 7 ++++++ home/manifests/echoserver/namespace.yaml | 4 ++++ home/manifests/echoserver/service.yaml | 13 ++++++++++ home/readme.md | 21 +++++++++------- home/talos/.gitignore | 3 --- ...plane.encrypted.yaml => controlplane.yaml} | 0 .../{talosconfig.encrypted => talosconfig} | 0 .../{worker.encrypted.yaml => worker.yaml} | 0 9 files changed, 61 insertions(+), 11 deletions(-) create mode 100644 home/manifests/echoserver/deployment.yaml create mode 100644 home/manifests/echoserver/kustomization.yaml create mode 100644 home/manifests/echoserver/namespace.yaml create mode 100644 home/manifests/echoserver/service.yaml delete mode 100644 home/talos/.gitignore rename home/talos/{controlplane.encrypted.yaml => controlplane.yaml} (100%) rename home/talos/{talosconfig.encrypted => talosconfig} (100%) rename home/talos/{worker.encrypted.yaml => worker.yaml} (100%) diff --git a/home/manifests/echoserver/deployment.yaml b/home/manifests/echoserver/deployment.yaml new file mode 100644 index 0000000..fbf71c2 --- /dev/null +++ b/home/manifests/echoserver/deployment.yaml @@ -0,0 +1,24 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: echoserver + namespace: echoserver +spec: + replicas: 1 + selector: + matchLabels: + app: echoserver + template: + metadata: + labels: + app: echoserver + spec: + containers: + - image: nginx:1.23.0-alpine + imagePullPolicy: IfNotPresent + name: echoserver + ports: + - containerPort: 80 + env: + - name: PORT + value: "80" diff --git a/home/manifests/echoserver/kustomization.yaml b/home/manifests/echoserver/kustomization.yaml new file mode 100644 index 0000000..4ffe4ee --- /dev/null +++ b/home/manifests/echoserver/kustomization.yaml @@ -0,0 +1,7 @@ +--- +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +resources: + - namespace.yaml + - service.yaml + - deployment.yaml diff --git a/home/manifests/echoserver/namespace.yaml b/home/manifests/echoserver/namespace.yaml new file mode 100644 index 0000000..8a31912 --- /dev/null +++ b/home/manifests/echoserver/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: echoserver diff --git a/home/manifests/echoserver/service.yaml b/home/manifests/echoserver/service.yaml new file mode 100644 index 0000000..dca3ece --- /dev/null +++ b/home/manifests/echoserver/service.yaml @@ -0,0 +1,13 @@ +apiVersion: v1 +kind: Service +metadata: + name: echoserver + namespace: echoserver +spec: + ports: + - port: 80 + targetPort: 80 + protocol: TCP + type: LoadBalancer + selector: + app: echoserver diff --git a/home/readme.md b/home/readme.md index 88c32f5..2c24bbd 100644 --- a/home/readme.md +++ b/home/readme.md @@ -1,5 +1,7 @@ # Home Cluster +> **NOTE**: Scripts below are in `fish` shell. + ## TODO - **Netboot**: https://www.sidero.dev/v0.5/getting-started/prereq-dhcp/ @@ -20,19 +22,23 @@ > **Source**: https://www.talos.dev/v1.1/introduction/getting-started/ +- Setup talos directory if needed + - `mkdir -p talos; cd talos` - Boot the Talos image on the initial node - If you are not using _this_ configuration: - - `talosctl gen config "cluster-name" "cluster-endpoint"` + - `talosctl gen config "$CLUSTER_NAME" "$CLUSTER_ENDPOINT"` - Edit files as needed + - Encrypt via `sops` with `age` + - `for f in *; sops --encrypt --age-key "$AGE_KEY" --in-place "$f"; end` - Apply the control plane config to the initial node - - `talosctl apply-config --insecure --nodes "$INITIAL_NODE_ADDR" --file controlplane.yaml` + - `sops exec-file controlplane.yaml 'talosctl apply-config --insecure --nodes "$NODE_ADDR" --file {}'` - You will need to wait a bit for the configuration to be applied, Talos to install itself, for the node to reboot, and for post-boot initialization - Setup the client to communicate with the newly-configured node - - `talosctl --talosconfig=./talosconfig config endpoint "$INITIAL_NODE_ADDR"` - - Optionally also make this the default with `talosctl config merge ./talosconfig` + - `sops --set '["contexts"]["'"$CLUSTER_NAME"'"]["endpoints"] ["'"$NODE_ADDR"'"]' talosconfig` + - Optionally also make this the default in `~/.talos/config` with `sops exec-file talosconfig 'talosctl config merge {}'` - Bootstrap the cluster - - `talosctl bootstrap --nodes "$INITIAL_NODE_ADDR"` + - `talosctl bootstrap --nodes "$NODE_ADDR"` - You will need to wait a bit for Kubernetes to initialize - Pull down the kubeconfig - `talosctl kubeconfig` @@ -44,12 +50,11 @@ able to `kubectl get nodes`. > **Note**: UNTESTED -- Boot the Talos ISO on the target node +- Boot the Talos image on the target node - Apply the appropriate configuration to the target node - - `talosctl apply-config --insecure --nodes "$TARGET_NODE_ADDR" --file controlplane.yaml` + - `sops exec-file "$CONFIG_FILE" 'talosctl apply-config --insecure --nodes "$NODE_ADDR" --file {}'` - You will need to wait a bit for Kubernetes to initialize, start up, and then join the cluster -- Add the node to `talosconfig` as needed #### Untaint Masters diff --git a/home/talos/.gitignore b/home/talos/.gitignore deleted file mode 100644 index 88a078c..0000000 --- a/home/talos/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -talosconfig -*.yaml -!*.encrypted.yaml diff --git a/home/talos/controlplane.encrypted.yaml b/home/talos/controlplane.yaml similarity index 100% rename from home/talos/controlplane.encrypted.yaml rename to home/talos/controlplane.yaml diff --git a/home/talos/talosconfig.encrypted b/home/talos/talosconfig similarity index 100% rename from home/talos/talosconfig.encrypted rename to home/talos/talosconfig diff --git a/home/talos/worker.encrypted.yaml b/home/talos/worker.yaml similarity index 100% rename from home/talos/worker.encrypted.yaml rename to home/talos/worker.yaml