Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add lima provider for macOS #1536

Merged
merged 33 commits into from
Sep 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
57dff1b
Add yaml wraper
nirs Aug 29, 2024
5dcb66f
Add kubeconfig module
nirs Aug 29, 2024
889fa30
Update kubectl-gather to 0.5.1
nirs Sep 4, 2024
559674a
Add setup for macOS
nirs Sep 4, 2024
4085ea9
Add lima provider for Apple silicon
nirs Aug 29, 2024
30b1494
Add development environment for lima
nirs Sep 2, 2024
465467e
Add a delay after starting a stopped cluster
nirs Sep 2, 2024
80d5415
Log limactl errors
nirs Sep 9, 2024
3593ea8
Log invalid json logs in debug mode
nirs Sep 12, 2024
03efd51
Disable port forwarding
nirs Aug 30, 2024
24cf10d
Change API server to use the shared network
nirs Aug 30, 2024
fc5c1cc
Configure kubelet to use the right IP address
nirs Aug 31, 2024
3e52ba6
Configure kubelet to pull images in parallel
nirs Aug 31, 2024
903aaf4
Configure kubelet feature gates
nirs Sep 1, 2024
f885412
Increase fs.inotify limits
nirs Sep 5, 2024
043ced2
Update minio to latest release
nirs Aug 31, 2024
48c8a99
Use hostpath storage for minio
nirs Aug 31, 2024
57e7bfc
Support commands reading from stdin
nirs Sep 8, 2024
ee12fef
Support command work directory
nirs Sep 8, 2024
cbd2cd7
Introduce drenv load command
nirs Sep 8, 2024
7d4e8cd
Use drenv load to load images
nirs Aug 31, 2024
4efdcf7
Disable broker certificate check on macOS
nirs Sep 5, 2024
a6b43b8
Annotate nodes with submariner public ip
nirs Sep 6, 2024
13e763b
Promote vmnet shared network route
nirs Sep 8, 2024
babea99
Upgrade submariner to 0.18.0
nirs Sep 8, 2024
4f8deb4
Wait for all clusters before deploying submariner
nirs Sep 6, 2024
9a31fee
Simplify connectivity check
nirs Sep 7, 2024
f1fc909
Fix submariner test container to keep running
nirs Sep 7, 2024
9276a56
Enable submariner for lima
nirs Sep 8, 2024
e077171
Add external-snapshotter addon
nirs Sep 9, 2024
75dd239
Replace volumesnapshot with external-snapshotter
nirs Sep 9, 2024
b3b4a4e
Fix argocd deployment on macOS
nirs Sep 10, 2024
345418a
Avoid random failures when deleting environment
nirs Sep 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/user-quick-start.md
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ enough resources:
1. Install `subctl` tool, See
[Submariner subctl installation](https://submariner.io/operations/deployment/subctl/)
for the details.
Version v0.17.0 or later is required.
Version v0.18.0 or later is required.

1. Install the `velero` tool

Expand Down
4 changes: 2 additions & 2 deletions ramenctl/ramenctl/command.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ def run(*args):
return commands.run(*args)


def watch(*args, log=log.debug):
for line in commands.watch(*args):
def watch(*args, stderr=None, cwd=None, log=log.debug):
for line in commands.watch(*args, stderr=stderr, cwd=cwd):
log("%s", line)


Expand Down
45 changes: 26 additions & 19 deletions ramenctl/ramenctl/deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@

import concurrent.futures
import os
import subprocess
import tempfile

from drenv import kubectl

from . import command

IMAGE = "quay.io/ramendr/ramen-operator:latest"
Expand Down Expand Up @@ -33,32 +35,37 @@ def run(args):
command.info("Preparing resources")
command.watch("make", "-C", args.source_dir, "resources")

with tempfile.TemporaryDirectory(prefix="ramenctl-deploy-") as tmpdir:
tar = os.path.join(tmpdir, "image.tar")
command.info("Saving image '%s'", args.image)
command.watch("podman", "save", args.image, "-o", tar)
load_image(args)

with concurrent.futures.ThreadPoolExecutor() as executor:
futures = []
with concurrent.futures.ThreadPoolExecutor() as executor:
futures = []

if env["hub"]:
f = executor.submit(
deploy, args, env["hub"], tar, "hub", platform="k8s"
)
futures.append(f)
if env["hub"]:
f = executor.submit(deploy, args, env["hub"], "hub", platform="k8s")
futures.append(f)

for cluster in env["clusters"]:
f = executor.submit(deploy, args, cluster, tar, "dr-cluster")
futures.append(f)
for cluster in env["clusters"]:
f = executor.submit(deploy, args, cluster, "dr-cluster")
futures.append(f)

for f in concurrent.futures.as_completed(futures):
f.result()
for f in concurrent.futures.as_completed(futures):
f.result()


def deploy(args, cluster, tar, deploy_type, platform="", timeout=120):
command.info("Loading image in cluster '%s'", cluster)
command.watch("minikube", "--profile", cluster, "image", "load", tar)
def load_image(args):
command.info("Loading image '%s'", args.image)
with tempfile.TemporaryDirectory(prefix="ramenctl-deploy-") as tmpdir:
tar = os.path.join(tmpdir, "image.tar")
command.watch("podman", "save", args.image, "-o", tar)
cmd = ["drenv", "load", f"--image={tar}"]
if args.name_prefix:
cmd.append(f"--name-prefix={args.name_prefix}")
cmd.append(os.path.abspath(args.filename))
work_dir = os.path.join(args.source_dir, "test") if args.source_dir else None
command.watch(*cmd, stderr=subprocess.STDOUT, cwd=work_dir)


def deploy(args, cluster, deploy_type, platform="", timeout=120):
command.info("Deploying ramen operator in cluster '%s'", cluster)
overlay = os.path.join(args.source_dir, f"config/{deploy_type}/default", platform)
yaml = kubectl.kustomize(overlay, load_restrictor="LoadRestrictionsNone")
Expand Down
76 changes: 72 additions & 4 deletions test/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ SPDX-License-Identifier: Apache-2.0
This directory provides tools and configuration for creating Ramen test
environment.

## Setup
## Setup on Linux

1. Setup a development environment as describe in
[developer quick start guide](../docs/devel-quick-start.md)
Expand Down Expand Up @@ -41,7 +41,7 @@ environment.
1. Install `subctl` tool, See
[Submariner subctl installation](https://submariner.io/operations/deployment/subctl/)
for the details.
Version v0.17.0 or later is required.
Version v0.18.0 or later is required.

1. Install the `velero` tool

Expand Down Expand Up @@ -110,14 +110,82 @@ environment.
1. Install the `kubectl-gather` plugin

```
curl -L -o kubectl-gather https://github.com/nirs/kubectl-gather/releases/download/v0.4.1/kubectl-gather-v0.4.1-linux-amd64
curl -L -o kubectl-gather https://github.com/nirs/kubectl-gather/releases/download/v0.5.1/kubectl-gather-v0.5.1-linux-amd64
sudo install kubectl-gather /usr/local/bin
rm kubectl-gather
```

For more info see [kubectl-gather](https://github.com/nirs/kubectl-gather)

### Testing that drenv is healthy
## Setup on macOS

1. Install the [Homebrew package manager](https://brew.sh/)

1. Install required packages

```
brew install go kubectl kustomize helm velero virtctl minio-mc argocd
```

1. Install the `clusteradm` tool. See
[Install clusteradm CLI tool](https://open-cluster-management.io/getting-started/installation/start-the-control-plane/#install-clusteradm-cli-tool)
for the details. Version v0.8.1 or later is required.

1. Install the `subctl` tool, See
[Submariner subctl installation](https://submariner.io/operations/deployment/subctl/)
for the details. Version v0.18.0 or later is required.

1. Install the `kubectl-gather` plugin

```
curl -L -o kubectl-gather https://github.com/nirs/kubectl-gather/releases/download/v0.5.1/kubectl-gather-v0.5.1-darwin-arm64
sudo install kubectl-gather /usr/local/bin
rm kubectl-gather
```

For more info see [kubectl-gather](https://github.com/nirs/kubectl-gather)

1. Install `lima` from source

> [!NOTE]
> Do not install lima from brew, it is too old.

Clone and build lima:

```
git clone https://github.com/lima-vm/lima.git
cd lima
make
```

Edit `~/.zshrc` and add `$HOME/lima/_output/bin` directory to the PATH:

```
PATH="$HOME/lima/_output/bin:$PATH"
export PATH
```

Open a new shell or run this in the current shell:

```
export PATH="$HOME/lima/_output/bin:$PATH"
```

1. Install `socket_vmnet` from source

> [!IMPORTANT]
> Do not install socket_vmnet from brew, it is insecure.

```
git clone https://github.com/lima-vm/socket_vmnet.git
cd socket_vmnet
sudo make PREFIX=/opt/socket_vmnet install.bin
sudo make PREFIX=/opt/socket_vmnet install.launchd
```

For more info see [Installing socket_vmnet from source](https://github.com/lima-vm/socket_vmnet?tab=readme-ov-file#from-source)

## Testing that drenv is healthy

Run this script to make sure `drenv` works:

Expand Down
11 changes: 11 additions & 0 deletions test/addons/external-snapshotter/cache
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

import os
from drenv import cache

os.chdir(os.path.dirname(__file__))
cache.refresh("crds", "addons/external-snapshotter-crds-8.1.0.yaml")
cache.refresh("controller", "addons/external-snapshotter-controller-8.1.0.yaml")
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
resources:
- https://github.com/kubernetes-csi/external-snapshotter/deploy/kubernetes/snapshot-controller?ref=v8.1.0
namespace: kube-system
3 changes: 3 additions & 0 deletions test/addons/external-snapshotter/crds/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
resources:
- https://github.com/kubernetes-csi/external-snapshotter/client/config/crd?ref=v8.1.0
45 changes: 45 additions & 0 deletions test/addons/external-snapshotter/start
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env python3

# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

import os
import sys

from drenv import kubectl
from drenv import cache


def deploy(cluster):
print("Deploying crds")
path = cache.get("crds", "addons/external-snapshotter-crds-8.1.0.yaml")
kubectl.apply("--filename", path, context=cluster)

print("Waiting until crds are established")
kubectl.wait("--for=condition=established", "--filename", path, context=cluster)

print("Deploying snapshot-controller")
path = cache.get("controller", "addons/external-snapshotter-controller-8.1.0.yaml")
kubectl.apply("--filename", path, context=cluster)


def wait(cluster):
print("Waiting until snapshot-controller is rolled out")
kubectl.rollout(
"status",
"deploy/snapshot-controller",
"--namespace=kube-system",
"--timeout=300s",
context=cluster,
)


if len(sys.argv) != 2:
print(f"Usage: {sys.argv[0]} cluster")
sys.exit(1)

os.chdir(os.path.dirname(__file__))
cluster = sys.argv[1]

deploy(cluster)
wait(cluster)
22 changes: 19 additions & 3 deletions test/addons/minio/minio.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,31 @@ metadata:
name: minio
---
apiVersion: v1
kind: PersistentVolume
metadata:
name: minio-storage-pv
labels:
component: minio
spec:
storageClassName: manual
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: /mnt/minio
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
namespace: minio
name: minio-storage-pvc
labels:
component: minio
spec:
accessModes: ["ReadWriteOnce"]
storageClassName: "standard"
accessModes:
- ReadWriteOnce
storageClassName: manual
resources:
requests:
storage: 10Gi
Expand Down Expand Up @@ -47,7 +63,7 @@ spec:
readOnly: false
containers:
- name: minio
image: quay.io/minio/minio:RELEASE.2024-03-15T01-07-19Z
image: quay.io/minio/minio:RELEASE.2024-08-29T01-40-52Z
imagePullPolicy: IfNotPresent
resources:
limits:
Expand Down
16 changes: 16 additions & 0 deletions test/addons/rook-pool/snapshot-class.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# SPDX-FileCopyrightText: The RamenDR authors
# SPDX-License-Identifier: Apache-2.0

# yamllint disable rule:line-length
# Drived from https://raw.githubusercontent.com/rook/rook/release-1.15/deploy/examples/csi/rbd/snapshotclass.yaml
---
apiVersion: snapshot.storage.k8s.io/v1
kind: VolumeSnapshotClass
metadata:
name: csi-rbdplugin-snapclass
driver: rook-ceph.rbd.csi.ceph.com
parameters:
clusterID: rook-ceph
csi.storage.k8s.io/snapshotter-secret-name: rook-csi-rbd-provisioner
csi.storage.k8s.io/snapshotter-secret-namespace: rook-ceph
deletionPolicy: Delete
3 changes: 2 additions & 1 deletion test/addons/rook-pool/start
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,11 @@ from drenv import kubectl


def deploy(cluster):
print("Creating rbd pool and storage class")
print("Creating RBD pool and storage/snapshot classes")
kubectl.apply(
"--filename=replica-pool.yaml",
"--filename=storage-class.yaml",
"--filename=snapshot-class.yaml",
context=cluster,
)

Expand Down
6 changes: 4 additions & 2 deletions test/addons/submariner/base/src/pod.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,7 @@ spec:
- -c
- |
trap exit TERM
sleep 300 &
wait
while true; do
sleep 10 &
wait
done
Loading
Loading