From c250b6f617bc30e04f32be0ca58309a51b762153 Mon Sep 17 00:00:00 2001 From: Rohit Kumar Date: Thu, 10 Oct 2024 14:22:25 +0530 Subject: [PATCH] Add manifests to create a machine with non-ephemeral resources --- .../README.md | 29 ++++++++++ .../kustomization.yaml | 14 +++++ .../manifests/ignition-secret.yaml | 7 +++ .../manifests/ignition.yaml | 57 +++++++++++++++++++ .../manifests/index.html | 31 ++++++++++ .../manifests/install-nginx.sh | 4 ++ .../manifests/machine.yaml | 20 +++++++ .../manifests/networking.yaml | 27 +++++++++ .../manifests/regenerate-ignition.sh | 5 ++ .../manifests/volume.yaml | 10 ++++ .../patch-machineclassref.yaml | 9 +++ .../patch-volume.yaml | 10 ++++ 12 files changed, 223 insertions(+) create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/README.md create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/kustomization.yaml create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/ignition-secret.yaml create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/ignition.yaml create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/index.html create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/install-nginx.sh create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/machine.yaml create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/networking.yaml create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/regenerate-ignition.sh create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/volume.yaml create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/patch-machineclassref.yaml create mode 100644 config/samples/e2e/machine-wtih-non-ephemeral-resource/patch-volume.yaml diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/README.md b/config/samples/e2e/machine-wtih-non-ephemeral-resource/README.md new file mode 100644 index 000000000..d14756207 --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/README.md @@ -0,0 +1,29 @@ +# Machine Sample deployement + +This example deploys a `Machine` with `non-ephemeral` `volume` and `networkinterface`. +The following artifacts will be deployed in your namespace: +- IronCore `Network`, `NetworkInterface` and `VirtualIP` +- IronCore `Machine` +- IronCore `Volume` +- Secret containing the `ignition` + +## Prerequisites + +- [Butane](https://coreos.github.io/butane/) + +## Usage +1. Adapt the `namespace` in `kustomization.yaml` +2. Replace `your-user` [^1], `your-pw-hash` [^2] and `your-ssh-key` [^3] in the `ignition.yaml` +3. Run `regenerate-ignition.sh` +4. Update the `patch-machineclassref.yaml` and `patch-volume.yaml` with the desired `machineClassRef` name and `volumeClassRef` name +5. Run (`kubectl apply -k ./`) + + +[^1]: e.g. `max` +[^2]: e.g. `$6$pCNgiQprrT/EmeE5$G7wa6wYm1FyuBHeVsuyH9IXGju07csuFwtrynslvSz6O.wFv4Ub8ADPqlBseewQQZQfp.9LCkWyodvJQjH.fe0` +[^3]: e.g. `ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAklOUpkDHrfHY17SbrmTIpNLTGK9Tjom/BWDSU +GPl+nafzlHDTYW7hdI4yZ5ew18JH4JW9jbhUFrviQzM7xlELEVf4h9lFX5QVkbPppSwg0cda3 +Pbv7kOdJ/MTyBlWXFCR+HAo3FXRitBqxiX1nKhXpHAZsMciLq8V6RjsNAQwdsdMFvSlVK/7XA +t3FaoJoAsncM1Q9x5+3V0Ww68/eIFmb1zuUFljQJKprrX88XypNDvjYNby6vw/Pb0rwert/En +mZ+AW4OZPnTPI89ZPmVMLuayrD2cE86Z/il8b+gw3r3+1nKatmIkjn2so1d01QraTlMqVSsbx +NrRFi9wrf+M7Q== max@mylaptop.local` \ No newline at end of file diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/kustomization.yaml b/config/samples/e2e/machine-wtih-non-ephemeral-resource/kustomization.yaml new file mode 100644 index 000000000..9eeb2818f --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/kustomization.yaml @@ -0,0 +1,14 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization + +namespace: test + +resources: +- ./manifests/ignition-secret.yaml +- ./manifests/networking.yaml +- ./manifests/volume.yaml +- ./manifests/machine.yaml + +patches: +- path: patch-machineclassref.yaml +- path: patch-volume.yaml diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/ignition-secret.yaml b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/ignition-secret.yaml new file mode 100644 index 000000000..f37bc0dbc --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/ignition-secret.yaml @@ -0,0 +1,7 @@ +apiVersion: v1 +data: + ignition.yaml: eyJpZ25pdGlvbiI6eyJ2ZXJzaW9uIjoiMy4zLjAifSwicGFzc3dkIjp7InVzZXJzIjpbeyJncm91cHMiOlsid2hlZWwiXSwiaG9tZURpciI6Ii9ob21lL3lvdXItdXNlciIsIm5hbWUiOiJ5b3VyLXVzZXIiLCJwYXNzd29yZEhhc2giOiJ5b3VyLXB3LWhhc2giLCJzaGVsbCI6Ii9iaW4vYmFzaCJ9XX0sInN0b3JhZ2UiOnsiZGlyZWN0b3JpZXMiOlt7Imdyb3VwIjp7Im5hbWUiOiJ5b3VyLXVzZXIifSwicGF0aCI6Ii9ob21lL3lvdXItdXNlci8uc3NoIiwidXNlciI6eyJuYW1lIjoieW91ci11c2VyIn0sIm1vZGUiOjQ0OH1dLCJmaWxlcyI6W3sicGF0aCI6Ii9ldGMvc3lzdGVtZC9yZXNvbHZlZC5jb25mLmQvZG5zLmNvbmYiLCJjb250ZW50cyI6eyJjb21wcmVzc2lvbiI6IiIsInNvdXJjZSI6ImRhdGE6LCU1QlJlc29sdmUlNUQlMEFETlMlM0QxLjEuMS4xJTBBIn0sIm1vZGUiOjQyMH0seyJncm91cCI6eyJuYW1lIjoieW91ci11c2VyIn0sInBhdGgiOiIvaG9tZS95b3VyLXVzZXIvLnNzaC9hdXRob3Jp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PTkVSbmZYRjVuMWNISGdRanVMbjVxeTVqM1Y2c1V0QUwyczFDd05QN2psVjBnN1YwdTNVbGZMNWR0WDBHZHowenJwaHZVNExTNXh0SnlvcUduN3VORUpkenFnaTdwbW16WG1USksxNTViTFByWUs5SVVUaExIUlJ4K3BkYkh3MU1nTmZPbjNhamE0d3kzbGdwcUdyTUMwOGE3dEJOWVN4OUtOSlQxcnhkRXRqWFovSmQ2UUZhUHhyT3U2ZHR2VGFFemg0ODl4eEtyRi9GemswTk5LWWQ5N1oxRWNSNzNCTFU3Z3FkOC95NitEOEgxMDh1Nzk3ZUxwS1JnOWZpSCtCUUFBLy8rZzN3bkVLQVFBQUE9PSJ9LCJtb2RlIjo0Mzh9XX0sInN5c3RlbWQiOnsidW5pdHMiOlt7ImVuYWJsZWQiOnRydWUsIm5hbWUiOiJzc2guc2VydmljZSJ9LHsiY29udGVudHMiOiJbVW5pdF1cbkRlc2NyaXB0aW9uPUluc3RhbGwgd2ViYXBwXG5bU2VydmljZV1cblR5cGU9b25lc2hvdFxuUmVtYWluQWZ0ZXJFeGl0PXllc1xuRXhlY1N0YXJ0PS9pbnN0YWxsLXdlYmFwcC5zaFxuW0luc3RhbGxdXG5XYW50ZWRCeT1tdWx0aS11c2VyLnRhcmdldCIsImVuYWJsZWQiOnRydWUsIm5hbWUiOiJpbnN0YWxsLXdlYmFwcC5zZXJ2aWNlIn1dfX0K +kind: Secret +metadata: + creationTimestamp: null + name: ignition \ No newline at end of file diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/ignition.yaml b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/ignition.yaml new file mode 100644 index 000000000..8415072ae --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/ignition.yaml @@ -0,0 +1,57 @@ + +variant: fcos +version: 1.4.0 +passwd: + users: + - name: your-user + home_dir: /home/your-user + groups: + - wheel + shell: /bin/bash + password_hash: : your-pw-hash +storage: + directories: + - path: /home/your-user/.ssh + mode: 0700 + user: + name: your-user + group: + name: your-user + files: + - path: /etc/systemd/resolved.conf.d/dns.conf + mode: 0644 + contents: + inline: | + [Resolve] + DNS=1.1.1.1 + - path: /home/your-user/.ssh/authorized_keys + mode: 0600 + user: + name: your-user + group: + name: your-user + contents: + inline: your-ssh-key + - path: /install-nginx.sh + mode: 0777 + contents: + local: install-nginx.sh + - path: /var/www/html/index.html + mode: 0666 + contents: + local: index.html +systemd: + units: + - name: ssh.service + enabled: true + - name: install-nginx.service + enabled: true + contents: | + [Unit] + Description=Install nginx + [Service] + Type=oneshot + RemainAfterExit=yes + ExecStart=/install-nginx.sh + [Install] + WantedBy=multi-user.target diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/index.html b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/index.html new file mode 100644 index 000000000..d81182c71 --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/index.html @@ -0,0 +1,31 @@ + +Hello Gardener Community! + + + + + + +
+
+
+ +

IronCore

+
+ IronCore Logo + IroneCore Project +
+
+
+ + + \ No newline at end of file diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/install-nginx.sh b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/install-nginx.sh new file mode 100644 index 000000000..7409b74d7 --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/install-nginx.sh @@ -0,0 +1,4 @@ +#!/usr/bin/env bash + +apt-get update +apt-get -yq install nginx \ No newline at end of file diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/machine.yaml b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/machine.yaml new file mode 100644 index 000000000..1c5af42e8 --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/machine.yaml @@ -0,0 +1,20 @@ +apiVersion: compute.ironcore.dev/v1alpha1 +kind: Machine +metadata: + name: machine-sample +spec: + machineClassRef: + name: machineclass-sample + volumes: + - name: rootdisk # first disk is root disk + volumeRef: + name: volume-sample + ignitionRef: + name: ignition + key: ignition.yaml + networkInterfaces: + - name: primary + networkInterfaceRef: + name: networkinterface-sample + + diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/networking.yaml b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/networking.yaml new file mode 100644 index 000000000..1fc910ed7 --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/networking.yaml @@ -0,0 +1,27 @@ +apiVersion: networking.ironcore.dev/v1alpha1 +kind: Network +metadata: + name: network-sample +--- +apiVersion: networking.ironcore.dev/v1alpha1 +kind: VirtualIP +metadata: + name: virtualip-sample +spec: + type: Public + ipFamily: IPv4 +--- +apiVersion: networking.ironcore.dev/v1alpha1 +kind: NetworkInterface +metadata: + name: networkinterface-sample +spec: + networkRef: + name: network-sample + ipFamilies: + - IPv4 + ips: + - value: 10.0.0.1 # internal IP + virtualIP: + virtualIPRef: + name: virtualip-sample \ No newline at end of file diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/regenerate-ignition.sh b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/regenerate-ignition.sh new file mode 100644 index 000000000..65d18cb34 --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/regenerate-ignition.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash + +butane -d . ignition.yaml | \ + kubectl create secret generic ignition --from-file=ignition.yaml=/dev/stdin --dry-run=client -o yaml \ + > ignition-secret.yaml \ No newline at end of file diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/volume.yaml b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/volume.yaml new file mode 100644 index 000000000..fc08d2dcc --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/manifests/volume.yaml @@ -0,0 +1,10 @@ +apiVersion: storage.ironcore.dev/v1alpha1 +kind: Volume +metadata: + name: volume-sample +spec: + volumeClassRef: + name: volumeclass-sample + image: gardenlinux:rootfs-image + resources: + storage: 10Gi diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/patch-machineclassref.yaml b/config/samples/e2e/machine-wtih-non-ephemeral-resource/patch-machineclassref.yaml new file mode 100644 index 000000000..9bee54ea4 --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/patch-machineclassref.yaml @@ -0,0 +1,9 @@ +apiVersion: compute.ironcore.dev/v1alpha1 +kind: Machine +metadata: + name: machine-sample +spec: + machineClassRef: + name: new-machineclass-sample # The new name of the machine class reference + machinePoolRef: + name: new-machine-pool \ No newline at end of file diff --git a/config/samples/e2e/machine-wtih-non-ephemeral-resource/patch-volume.yaml b/config/samples/e2e/machine-wtih-non-ephemeral-resource/patch-volume.yaml new file mode 100644 index 000000000..33d57d702 --- /dev/null +++ b/config/samples/e2e/machine-wtih-non-ephemeral-resource/patch-volume.yaml @@ -0,0 +1,10 @@ +apiVersion: storage.ironcore.dev/v1alpha1 +kind: Volume +metadata: + name: volume-sample +spec: + volumeClassRef: + name: new-volumeclass-sample # The new name of the volume class reference + image: new-image:rootfs-abc + volumePoolRef: + name: new-volume-pool \ No newline at end of file