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

vCenter and Boskos config for the vSphere environment #1

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
93 changes: 93 additions & 0 deletions vsphere-boskos-poc/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# vCenter

Create via:
```bash
# Create terraform.tfvars in vsphere folder:
# vsphere_password = ""
# vsphere_server = ""
# vsphere_user = "[email protected]"

cd ./vsphere

docker run -ti --rm -v $(pwd):/data ubuntu:22.04 /bin/bash

cd /data
apt-get update
apt-get install -y curl vim
# tfswitch install to manage terraform version
curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/master/install.sh | bash
# Run tfswitch to download terraform
tfswitch

# Run terraform
terraform init
terraform plan
terraform apply
```

# Boskos


```bash
cd ./boskos

export KUBECONFIG=***

kubectl apply -f ./namespace.yaml
kubectl apply -f ./boskos-resources-configmap.yaml
kubectl apply -f ./boskos.yaml
kubectl apply -f ./boskos-reaper-deployment.yaml
```

Init resources

```bash
cd ./boskos

export BOSKOS_HOST=http://192.168.6.138:32222

# Check connectivity
curl -k -v ${BOSKOS_HOST}/metrics

# Acquire all resources (repeat command until all are acquired)
# Initializing
while true; do curl -X POST "${BOSKOS_HOST}/acquire?type=vsphere-project-cloud-provider&state=initializing&dest=busy&owner=$(whoami)"; done
while true; do curl -X POST "${BOSKOS_HOST}/acquire?type=vsphere-project-cluster-api-provider&state=initializing&dest=busy&owner=$(whoami)"; done
while true; do curl -X POST "${BOSKOS_HOST}/acquire?type=vsphere-project-image-builder&state=initializing&dest=busy&owner=$(whoami)"; done

# Free
while true; do curl -X POST "${BOSKOS_HOST}/acquire?type=vsphere-project-cloud-provider&state=free&dest=busy&owner=$(whoami)"; done
while true; do curl -X POST "${BOSKOS_HOST}/acquire?type=vsphere-project-cluster-api-provider&state=free&dest=busy&owner=$(whoami)"; done
while true; do curl -X POST "${BOSKOS_HOST}/acquire?type=vsphere-project-image-builder&state=free&dest=busy&owner=$(whoami)"; done

# Dirty
while true; do curl -X POST "${BOSKOS_HOST}/acquire?type=vsphere-project-cloud-provider&state=dirty&dest=busy&owner=$(whoami)"; done
while true; do curl -X POST "${BOSKOS_HOST}/acquire?type=vsphere-project-cluster-api-provider&state=dirty&dest=busy&owner=$(whoami)"; done
while true; do curl -X POST "${BOSKOS_HOST}/acquire?type=vsphere-project-image-builder&state=dirty&dest=busy&owner=$(whoami)"; done


# Add user data (using homebrew / mikefarah/yq)
for resourceType in $(yq eval '.resources[].type' boskos-resources-user-data.yaml); do
echo "Adding userdata to resources of type $resourceType"
for resourceName in $(yq eval '.resources[] | select(.type=="'$resourceType'") | .resources[].name' boskos-resources-user-data.yaml); do
echo "Adding userdata to resource $resourceName"

userData=$(yq eval '.resources[] | select(.type=="'${resourceType}'") | .resources[] | select(.name=="'${resourceName}'") | .userData' boskos-resources-user-data.yaml)

resourcePool="$(echo $userData | yq eval '.resourcePool')"
folder="$(echo $userData | yq eval '.folder')"
ipPool="$(echo $userData | yq eval '.ipPool')"

curl -X POST -d '{"ipPool":"'${ipPool}'","resourcePool":"'${resourcePool}'","folder":"'${folder}'"}' "${BOSKOS_HOST}/update?name=${resourceName}&state=busy&owner=$(whoami)" -v
done
done

# Release resources
for resourceType in $(yq eval '.resources[].type' boskos-resources-user-data.yaml); do
echo "Releasing resources of type $resourceType"
for resourceName in $(yq eval '.resources[] | select(.type=="'$resourceType'") | .resources[].name' boskos-resources-user-data.yaml); do
echo "Releasing resource $resourceName"
curl -X POST "${BOSKOS_HOST}/release?name=${resourceName}&dest=free&owner=$(whoami)"
done
done
```
Binary file added vsphere-boskos-poc/boskos.drawio.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
24 changes: 24 additions & 0 deletions vsphere-boskos-poc/boskos/boskos-reaper-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: boskos-reaper
labels:
app: boskos-reaper
namespace: test-pods
spec:
selector:
matchLabels:
app: boskos-reaper
replicas: 1 # one canonical source of resources
template:
metadata:
labels:
app: boskos-reaper
spec:
terminationGracePeriodSeconds: 30
containers:
- name: boskos-reaper
image: gcr.io/k8s-staging-boskos/reaper:v20240416-59dbd6c
args:
- --boskos-url=http://boskos.test-pods.svc.cluster.local.
- --resource-type=vsphere-project-cluster-api-provider,vsphere-project-cloud-provider,vsphere-project-image-builder
77 changes: 77 additions & 0 deletions vsphere-boskos-poc/boskos/boskos-resources-configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
apiVersion: v1
data:
config: |
resources:
- names:
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-001
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-002
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-003
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-004
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-005
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-006
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-007
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-008
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-009
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-010
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-011
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-012
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-013
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-014
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-015
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-016
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-017
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-018
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-019
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-020
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-021
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-022
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-023
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-024
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-025
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-026
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-027
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-028
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-029
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-030
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-031
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-032
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-033
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-034
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-035
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-036
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-037
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-038
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-039
- k8s-infra-e2e-boskos-vsphere-cluster-api-provider-vsphere-040
state: initializing
type: vsphere-project-cluster-api-provider
- names:
- k8s-infra-e2e-boskos-vsphere-cloud-provider-vsphere-001
- k8s-infra-e2e-boskos-vsphere-cloud-provider-vsphere-002
- k8s-infra-e2e-boskos-vsphere-cloud-provider-vsphere-003
- k8s-infra-e2e-boskos-vsphere-cloud-provider-vsphere-004
- k8s-infra-e2e-boskos-vsphere-cloud-provider-vsphere-005
- k8s-infra-e2e-boskos-vsphere-cloud-provider-vsphere-006
- k8s-infra-e2e-boskos-vsphere-cloud-provider-vsphere-007
- k8s-infra-e2e-boskos-vsphere-cloud-provider-vsphere-008
- k8s-infra-e2e-boskos-vsphere-cloud-provider-vsphere-009
- k8s-infra-e2e-boskos-vsphere-cloud-provider-vsphere-010
state: initializing
type: vsphere-project-cloud-provider
- names:
- k8s-infra-e2e-boskos-vsphere-image-builder-001
- k8s-infra-e2e-boskos-vsphere-image-builder-002
- k8s-infra-e2e-boskos-vsphere-image-builder-003
- k8s-infra-e2e-boskos-vsphere-image-builder-004
- k8s-infra-e2e-boskos-vsphere-image-builder-005
- k8s-infra-e2e-boskos-vsphere-image-builder-006
- k8s-infra-e2e-boskos-vsphere-image-builder-007
- k8s-infra-e2e-boskos-vsphere-image-builder-008
- k8s-infra-e2e-boskos-vsphere-image-builder-009
- k8s-infra-e2e-boskos-vsphere-image-builder-010
state: initializing
type: vsphere-project-image-builder
kind: ConfigMap
metadata:
name: resources
namespace: test-pods
Loading