-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
222 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/usr/bin/env bash | ||
#// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors | ||
#// SPDX-License-Identifier: Apache-2.0 | ||
|
||
update_settings(k8s_upsert_timeout_secs=60) # on first tilt up, often can take longer than 30 seconds | ||
|
||
settings = { | ||
"allowed_contexts": [ | ||
"kind-metal" | ||
], | ||
"kubectl": "./bin/kubectl", | ||
"cert_manager_version": "v1.15.3", | ||
} | ||
|
||
if "allowed_contexts" in settings: | ||
allow_k8s_contexts(settings.get("allowed_contexts")) | ||
|
||
def deploy_cert_manager(): | ||
kubectl = settings.get("kubectl") | ||
version = settings.get("cert_manager_version") | ||
print("Installing cert-manager") | ||
local("{} apply -f https://github.com/cert-manager/cert-manager/releases/download/{}/cert-manager.yaml".format(kubectl, version), quiet=True, echo_off=True) | ||
|
||
print("Waiting for cert-manager to start") | ||
local("{} wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager".format(kubectl), quiet=True, echo_off=True) | ||
local("{} wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager-cainjector".format(kubectl), quiet=True, echo_off=True) | ||
local("{} wait --for=condition=Available --timeout=300s -n cert-manager deployment/cert-manager-webhook".format(kubectl), quiet=True, echo_off=True) | ||
|
||
def waitforsystem(): | ||
kubectl = settings.get("kubectl") | ||
print("Waiting for metal-operator to start") | ||
local("{} wait --for=condition=ready --timeout=300s -n metal-operator-system pod --all".format(kubectl), quiet=False, echo_off=True) | ||
|
||
############################## | ||
# Actual work happens here | ||
############################## | ||
|
||
deploy_cert_manager() | ||
|
||
docker_build('controller', '.', target = 'manager') | ||
|
||
yaml = kustomize('./config/dev') | ||
|
||
k8s_yaml(yaml) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,13 @@ | ||
resources: | ||
- ../default | ||
- ../redfish-mockup | ||
|
||
patches: | ||
- path: delete_manager_auth_proxy_patch.yaml | ||
- path: manager_patch.yaml | ||
|
||
secretGenerator: | ||
- name: macdb | ||
namespace: metal-operator-system | ||
files: | ||
- macdb.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
macPrefixes: | ||
- macPrefix: 23 | ||
manufacturer: Foo | ||
protocol: RedfishLocal | ||
port: 8000 | ||
type: bmc | ||
defaultCredentials: | ||
- username: foo | ||
password: bar | ||
console: | ||
type: ssh | ||
port: 22 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
apiVersion: apps/v1 | ||
kind: Deployment | ||
metadata: | ||
name: controller-manager | ||
namespace: system | ||
spec: | ||
template: | ||
spec: | ||
containers: | ||
- name: manager | ||
args: | ||
- --health-probe-bind-address=:8081 | ||
- --metrics-bind-address=127.0.0.1:8080 | ||
- --leader-elect | ||
- --mac-prefixes-file=/etc/macdb/macdb.yaml | ||
- --probe-image=ghcr.io/ironcore-dev/metalprobe:latest | ||
- --probe-os-image=ghcr.io/ironcore-dev/os-images/gardenlinux:1443 | ||
- --registry-url=http://127.0.0.1:30000 | ||
ports: | ||
- containerPort: 30000 | ||
volumeMounts: | ||
- mountPath: /etc/macdb/ | ||
name: macdb | ||
- name: redfish | ||
image: dmtf/redfish-mockup-server:latest | ||
ports: | ||
- containerPort: 8000 | ||
securityContext: | ||
runAsNonRoot: false | ||
volumes: | ||
- name: macdb | ||
secret: | ||
defaultMode: 420 | ||
secretName: macdb |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
resources: | ||
- redfish_mockup_endpoint.yaml | ||
- redfish_mockup_service.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
apiVersion: metal.ironcore.dev/v1alpha1 | ||
kind: Endpoint | ||
metadata: | ||
labels: | ||
app.kubernetes.io/name: endpoint | ||
app.kubernetes.io/instance: endpoint-sample | ||
app.kubernetes.io/part-of: metal-operator | ||
app.kubernetes.io/managed-by: kustomize | ||
app.kubernetes.io/created-by: metal-operator | ||
name: endpoint-sample | ||
spec: | ||
ip: "127.0.0.1" | ||
macAddress: "23:11:8A:33:CF:EA" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
apiVersion: v1 | ||
kind: Service | ||
metadata: | ||
name: redfish | ||
namespace: metal-operator-system | ||
spec: | ||
ports: | ||
- port: 8000 | ||
targetPort: 8000 | ||
selector: | ||
control-plane: controller-manager |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
#!/usr/bin/env bash | ||
#// SPDX-FileCopyrightText: 2024 SAP SE or an SAP affiliate company and IronCore contributors | ||
#// SPDX-License-Identifier: Apache-2.0 | ||
|
||
set -o errexit | ||
set -o nounset | ||
set -o pipefail | ||
|
||
|
||
REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. | ||
KUBECTL=$REPO_ROOT/bin/kubectl | ||
|
||
# desired kind cluster name; default is "metal" | ||
KIND_CLUSTER_NAME="${KIND_CLUSTER_NAME:-metal}" | ||
|
||
if [[ "$(kind get clusters)" =~ .*"${KIND_CLUSTER_NAME}".* ]]; then | ||
echo "cluster already exists, moving on" | ||
exit 0 | ||
fi | ||
|
||
reg_name='kind-registry' | ||
reg_port="${KIND_REGISTRY_PORT:-5000}" | ||
|
||
# create registry container unless it already exists | ||
running="$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" | ||
if [ "${running}" != 'true' ]; then | ||
docker run -d --restart=always -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" registry:2 | ||
fi | ||
|
||
# create a cluster with the local registry enabled in containerd | ||
cat <<EOF | kind create cluster --name "${KIND_CLUSTER_NAME}" --config=- | ||
kind: Cluster | ||
apiVersion: kind.x-k8s.io/v1alpha4 | ||
containerdConfigPatches: | ||
- |- | ||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"] | ||
endpoint = ["http://${reg_name}:5000"] | ||
EOF | ||
|
||
# connect the registry to the cluster network | ||
# (the network may already be connected) | ||
docker network connect "kind" "${reg_name}" || true | ||
|
||
# Document the local registry | ||
# https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry | ||
cat <<EOF | kubectl apply --namespace=kube-public -f - | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: local-registry-hosting | ||
namespace: kube-public | ||
data: | ||
localRegistryHosting.v1: | | ||
host: "localhost:${reg_port}" | ||
help: "https://kind.sigs.k8s.io/docs/user/local-registry/" | ||
EOF | ||
|
||
"${KUBECTL}" wait node "${KIND_CLUSTER_NAME}-control-plane" --for=condition=ready --timeout=90s |