Skip to content

Commit

Permalink
Add e2e example for Machine creation using non ephemeral resources (#…
Browse files Browse the repository at this point in the history
…1133)

* Add manifests to create a machine with non-ephemeral resources

* update folder structure

* increase `eventuallyTimeout` to 10s to avoid sporadic core_test failure

* address review comments

* update the `eventuallyTimeout`  with 3s in `app_suite_test.go`
  • Loading branch information
Rohit-0505 authored Oct 21, 2024
1 parent daeb37f commit 8ea3843
Show file tree
Hide file tree
Showing 15 changed files with 229 additions and 1 deletion.
7 changes: 7 additions & 0 deletions config/samples/e2e/bases/ignition/ignition-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: v1
data:
ignition.yaml: eyJpZ25pdGlvbiI6eyJ2ZXJzaW9uIjoiMy4zLjAifSwicGFzc3dkIjp7InVzZXJzIjpbeyJncm91cHMiOlsid2hlZWwiXSwiaG9tZURpciI6Ii9ob21lL3lvdXItdXNlciIsIm5hbWUiOiJ5b3VyLXVzZXIiLCJwYXNzd29yZEhhc2giOiJ5b3VyLXB3LWhhc2giLCJzaGVsbCI6Ii9iaW4vYmFzaCJ9XX0sInN0b3JhZ2UiOnsiZGlyZWN0b3JpZXMiOlt7Imdyb3VwIjp7Im5hbWUiOiJ5b3VyLXVzZXIifSwicGF0aCI6Ii9ob21lL3lvdXItdXNlci8uc3NoIiwidXNlciI6eyJuYW1lIjoieW91ci11c2VyIn0sIm1vZGUiOjQ0OH1dLCJmaWxlcyI6W3sicGF0aCI6Ii9ldGMvc3lzdGVtZC9yZXNvbHZlZC5jb25mLmQvZG5zLmNvbmYiLCJjb250ZW50cyI6eyJjb21wcmVzc2lvbiI6IiIsInNvdXJjZSI6ImRhdGE6LCU1QlJlc29sdmUlNUQlMEFETlMlM0QxLjEuMS4xJTBBIn0sIm1vZGUiOjQyMH0seyJncm91cCI6eyJuYW1lIjoieW91ci11c2VyIn0sInBhdGgiOiIvaG9tZS95b3VyLXVzZXIvLnNzaC9hdXRob3JpemVkX2tleXMiLCJ1c2VyIjp7Im5hbWU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3Y1M0pRdEg2bFVMMjRCNkdXakZtcjR3VFcvQWpxNFVwcU51bHF2Mzc0U2ZUWTN0Wk9tMzQ3VDRpSUh5NUd5a3ZhUEJ4M3hvRnQwUVpkc2s4YVVTSkwyWEhQZWhWcUJ2bENDTURaNjBCRnJGekpQbGR6QWwrNm9Gb0VIM0ZQS3FLcklDa3dINytwR1lDdGhMTjFZMHJOV0RHcHBsUHNyOG82c0dJMW5YZGVsMjgrak1abVAyekJpeFdwNUxuTHFhS093Njd5ektJNkQzdUVlcCtEYzc1LzUxMTc0UGpoNTkvNTI5ZlFVNWovRXZ3QUFBUC8vbFFMTVdpOEVBQUE9In0sIm1vZGUiOjQzOH1dfSwic3lzdGVtZCI6eyJ1bml0cyI6W3siZW5hYmxlZCI6dHJ1ZSwibmFtZSI6InNzaC5zZXJ2aWNlIn0seyJjb250ZW50cyI6IltVbml0XVxuRGVzY3JpcHRpb249SW5zdGFsbCBuZ2lueFxuW1NlcnZpY2VdXG5UeXBlPW9uZXNob3RcblJlbWFpbkFmdGVyRXhpdD15ZXNcbkV4ZWNTdGFydD0vaW5zdGFsbC1uZ2lueC5zaFxuW0luc3RhbGxdXG5XYW50ZWRCeT1tdWx0aS11c2VyLnRhcmdldFxuIiwiZW5hYmxlZCI6dHJ1ZSwibmFtZSI6Imluc3RhbGwtbmdpbnguc2VydmljZSJ9XX19Cg==
kind: Secret
metadata:
creationTimestamp: null
name: ignition
57 changes: 57 additions & 0 deletions config/samples/e2e/bases/ignition/ignition.yaml
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
31 changes: 31 additions & 0 deletions config/samples/e2e/bases/ignition/index.html
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>
4 changes: 4 additions & 0 deletions config/samples/e2e/bases/ignition/install-nginx.sh
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
2 changes: 2 additions & 0 deletions config/samples/e2e/bases/ignition/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
resources:
- ignition-secret.yaml
5 changes: 5 additions & 0 deletions config/samples/e2e/bases/ignition/regenerate-ignition.sh
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/ignition-secret.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
resources:
- network.yaml
- virtualIP.yaml
- networkinterface.yaml
- volume.yaml
- machine.yaml
20 changes: 20 additions & 0 deletions config/samples/e2e/bases/nonephemeral-machine/machine.yaml
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


4 changes: 4 additions & 0 deletions config/samples/e2e/bases/nonephemeral-machine/network.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
apiVersion: networking.ironcore.dev/v1alpha1
kind: Network
metadata:
name: network-sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
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
7 changes: 7 additions & 0 deletions config/samples/e2e/bases/nonephemeral-machine/virtualIP.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
apiVersion: networking.ironcore.dev/v1alpha1
kind: VirtualIP
metadata:
name: virtualip-sample
spec:
type: Public
ipFamily: IPv4
10 changes: 10 additions & 0 deletions config/samples/e2e/bases/nonephemeral-machine/volume.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
53 changes: 53 additions & 0 deletions config/samples/e2e/machine-with-non-ephemeral-resource/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
# `Machine` non ephemeral resources

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`, `your-pw-hash` and `your-ssh-key` in the `ignition/ignition.yaml`
3. Run `ignition/regenerate-ignition.sh`
4. Create the below `patch-machineclassref.yaml` in `machine-with-non-ephemeral-resource` folder with the desired `machineClassRef` and `machinePoolRef` as per your environment

```
apiVersion: compute.ironcore.dev/v1alpha1
kind: Machine
metadata:
name: machine-sample
spec:
machineClassRef:
name: new-machineClass # The new name of the machine class reference
machinePoolRef:
name: new-machinePool
```

5. Create the below`patch-volume.yaml`in `machine-with-non-ephemeral-resource` folder with the desired `volumeClassRef`and `volumePoolRef` as per your environment

```
apiVersion: storage.ironcore.dev/v1alpha1
kind: Volume
metadata:
name: volume-sample
spec:
volumeClassRef:
name: new-volumeClass The new name of the volume class reference
image: new-image:rootfs
volumePoolRef:
name: new-volumePool
```
6. Update the `kustomization.yaml` with below content
```
patches:
- path: patch-machineclassref.yaml
- path: patch-volume.yaml
```

7. Run (`kubectl apply -k ./`)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

namespace: test

resources:
- ../bases/ignition
- ../bases/nonephemeral-machine
2 changes: 1 addition & 1 deletion internal/app/app_suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (

const (
pollingInterval = 50 * time.Millisecond
eventuallyTimeout = 5 * time.Second
eventuallyTimeout = 3 * time.Second
consistentlyDuration = 1 * time.Second
apiServiceTimeout = 5 * time.Minute
)
Expand Down

0 comments on commit 8ea3843

Please sign in to comment.