Skip to content

Commit

Permalink
Add manifests to create a machine with non-ephemeral resources
Browse files Browse the repository at this point in the history
  • Loading branch information
Rohit-0505 committed Oct 14, 2024
1 parent daeb37f commit c250b6f
Show file tree
Hide file tree
Showing 12 changed files with 223 additions and 0 deletions.
29 changes: 29 additions & 0 deletions config/samples/e2e/machine-wtih-non-ephemeral-resource/README.md
Original file line number Diff line number Diff line change
@@ -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== [email protected]`
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
data:
ignition.yaml: eyJpZ25pdGlvbiI6eyJ2ZXJzaW9uIjoiMy4zLjAifSwicGFzc3dkIjp7InVzZXJzIjpbeyJncm91cHMiOlsid2hlZWwiXSwiaG9tZURpciI6Ii9ob21lL3lvdXItdXNlciIsIm5hbWUiOiJ5b3VyLXVzZXIiLCJwYXNzd29yZEhhc2giOiJ5b3VyLXB3LWhhc2giLCJzaGVsbCI6Ii9iaW4vYmFzaCJ9XX0sInN0b3JhZ2UiOnsiZGlyZWN0b3JpZXMiOlt7Imdyb3VwIjp7Im5hbWUiOiJ5b3VyLXVzZXIifSwicGF0aCI6Ii9ob21lL3lvdXItdXNlci8uc3NoIiwidXNlciI6eyJuYW1lIjoieW91ci11c2VyIn0sIm1vZGUiOjQ0OH1dLCJmaWxlcyI6W3sicGF0aCI6Ii9ldGMvc3lzdGVtZC9yZXNvbHZlZC5jb25mLmQvZG5zLmNvbmYiLCJjb250ZW50cyI6eyJjb21wcmVzc2lvbiI6IiIsInNvdXJjZSI6ImRhdGE6LCU1QlJlc29sdmUlNUQlMEFETlMlM0QxLjEuMS4xJTBBIn0sIm1vZGUiOjQyMH0seyJncm91cCI6eyJuYW1lIjoieW91ci11c2VyIn0sInBhdGgiOiIvaG9tZS95b3VyLXVzZXIvLnNzaC9hdXRob3JpemVkX2tleXMiLCJ1c2VyIjp7Im5hbWUiOiJ5b3VyLXVzZXIifSwiY29udGVudHMiOnsiY29tcHJlc3Npb24iOiIiLCJzb3VyY2UiOiJkYXRhOix5b3VyLXNzaC1rZXkif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USksxNTViTFByWUs5SVVUaExIUlJ4K3BkYkh3MU1nTmZPbjNhamE0d3kzbGdwcUdyTUMwOGE3dEJOWVN4OUtOSlQxcnhkRXRqWFovSmQ2UUZhUHhyT3U2ZHR2VGFFemg0ODl4eEtyRi9GemswTk5LWWQ5N1oxRWNSNzNCTFU3Z3FkOC95NitEOEgxMDh1Nzk3ZUxwS1JnOWZpSCtCUUFBLy8rZzN3bkVLQVFBQUE9PSJ9LCJtb2RlIjo0Mzh9XX0sInN5c3RlbWQiOnsidW5pdHMiOlt7ImVuYWJsZWQiOnRydWUsIm5hbWUiOiJzc2guc2VydmljZSJ9LHsiY29udGVudHMiOiJbVW5pdF1cbkRlc2NyaXB0aW9uPUluc3RhbGwgd2ViYXBwXG5bU2VydmljZV1cblR5cGU9b25lc2hvdFxuUmVtYWluQWZ0ZXJFeGl0PXllc1xuRXhlY1N0YXJ0PS9pbnN0YWxsLXdlYmFwcC5zaFxuW0luc3RhbGxdXG5XYW50ZWRCeT1tdWx0aS11c2VyLnRhcmdldCIsImVuYWJsZWQiOnRydWUsIm5hbWUiOiJpbnN0YWxsLXdlYmFwcC5zZXJ2aWNlIn1dfX0K
kind: Secret
metadata:
creationTimestamp: null
name: ignition
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<html></html>
<title>Hello Gardener Community!</title>
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/css/materialize.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>
<style>
.mono {
font-family: monospace, monospace;
}
</style>
</head>
<body class="grey darken-4">
<div class="container">
<div class="row">
<div class="col s12 m6 offset-m3">
<u class="blue-text darken-4">
<h3 class="center-align blue-text darken-4 mono">IronCore</h3>
</u>
<img class="materiaboxed"
alt="IronCore Logo"
width="100%"
src="https://github.com/ironcore-dev/ironcore/raw/main/docs/assets/logo.png" />
<a style="margin-left: 7px" class="waves-effect waves-light btn mono blue darken-4">IroneCore Project</a>
</div>
</div>
</div>
</body>
<script type="application/javascript">
M.AutoInit();
</script>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env bash

apt-get update
apt-get -yq install nginx
Original file line number Diff line number Diff line change
@@ -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


Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c250b6f

Please sign in to comment.