Skip to content

Commit

Permalink
HOSTEDCP-1716: When running the HO locally it
Browse files Browse the repository at this point in the history
should no required a running pod

This PR covers the steps to run the HyperShift Operator locally without
needing access to a full production environment.

Fixes #HOSTEDCP-1716
  • Loading branch information
Marc Brown committed Jul 5, 2024
1 parent b2fe3e8 commit cc1aa3c
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 24 deletions.
2 changes: 1 addition & 1 deletion HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

2. Build HyperShift.

# requires go v1.16+
# requires go v1.22+
$ make build

3. Install HyperShift in development mode which causes the operator deployment
Expand Down
12 changes: 12 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ GO_E2E_RECIPE=CGO_ENABLED=1 $(GO) test $(GO_GCFLAGS) -tags e2e -c

OUT_DIR ?= bin

# run the HO locally
HYPERSHIFT_INSTALL_AWS := ./hack/dev/aws/hypershft-install-aws.sh
RUN_OPERATOR_LOCALLY_AWS := ./hack/dev/aws/run-operator-locally-aws.sh

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
Expand Down Expand Up @@ -286,3 +290,11 @@ ci-install-hypershift-private:
regenerate-pki:
REGENERATE_PKI=1 $(GO) test ./control-plane-pki-operator/...
REGENERATE_PKI=1 $(GO) test ./test/e2e/... -run TestRegeneratePKI

.PHONY: hypershift-install-aws-dev
hypershift-install-aws-dev:
@$(HYPERSHIFT_INSTALL_AWS)

.PHONY: run-operator-locally-aws-dev
run-operator-locally-aws-dev:
@$(RUN_OPERATOR_LOCALLY_AWS)
51 changes: 51 additions & 0 deletions docs/content/contribute/run-hypershift-operator-locally.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
---
title: Run the hypershift-operator locally
---

## Run the HyperShift Operator locally

To run the HyperShift Operator locally, follow these steps:

1. Ensure that the `KUBECONFIG` environment variable is set to a management cluster where HyperShift has not been installed yet.

```shell linenums="1"
export KUBECONFIG="/path/to/your/kubeconfig"
```

2. Build HyperShift.

!!! note

`requires go v1.22+

```shell linenums="1"
make build
```

3. Set the necessary environment variables

```shell linenums="1"
export HYPERSHIFT_REGION="your-region"
export HYPERSHIFT_BUCKET_NAME="your-bucket"
```

!!! note

`Consider setting HYPERSHIFT_REGION and HYPERSHIFT_BUCKET_NAME in your shell init script (e.g., $HOME/.bashrc).

!!! note

`Default values are provided for HYPERSHIFT_REGION and HYPERSHIFT_BUCKET_NAME so Step #4 will function without requiring you to export any values.

4. Install HyperShift in development mode which causes the operator deployment to be deployment scaled to zero so that it doesn't conflict with your local operator process (see [Prerequisites](../getting-started.md#prerequisites)):

```shell linenums="1"
make hypershift-install-aws-dev
```

5. Run the HyperShift operator locally.

```shell linenums="1"
make run-operator-locally-aws-dev
```

22 changes: 0 additions & 22 deletions docs/content/contribute/run-locally.md

This file was deleted.

3 changes: 2 additions & 1 deletion docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -263,4 +263,5 @@ nav:
- 'Onboard a Platform': contribute/onboard-a-platform.md
- 'Run Tests': contribute/run-tests.md
- 'Develop in Cluster': contribute/develop_in_cluster.md
- 'Conotribute to docs': contribute/contribute-docs.md
- 'Run hypershift-operator locally': contribute/run-hypershift-operator-locally.md
- 'Contribute to docs': contribute/contribute-docs.md
18 changes: 18 additions & 0 deletions hack/dev/aws/hypershift-install-aws-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash

set -euo pipefail

REGION="${HYPERSHIFT_REGION:-us-east-1}"
BUCKET_NAME="${HYPERSHIFT_BUCKET_NAME:-hypershift-ci-oidc}"
AWSCREDS="${HYPERSHIFT_AWS_CREDS:-$HOME/.aws/credentials}"

# Install hypershift
echo "Installing hypershift"
./bin/hypershift install \
--oidc-storage-provider-s3-credentials "${AWSCREDS}" \
--oidc-storage-provider-s3-region "${REGION}" \
--oidc-storage-provider-s3-bucket-name "${BUCKET_NAME}" \
--enable-defaulting-webhook=false \
--enable-conversion-webhook=false \
--enable-validating-webhook=false \
--development=true
25 changes: 25 additions & 0 deletions hack/dev/aws/run-operator-locally-aws-dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash

set -euo pipefail
export METRICS_SET="Telemetry"

export MY_NAMESPACE=hypershift
export MY_NAME=operator

REGION="${HYPERSHIFT_REGION:-us-east-1}"
BUCKET_NAME="${HYPERSHIFT_BUCKET_NAME:-hypershift-ci-oidc}"
AWSCREDS="${HYPERSHIFT_AWS_CREDS:-$HOME/.aws/credentials}"

# Run hypershift-operator locally.
echo "Running hypershift-operator locally..."
./bin/hypershift-operator \
run \
--metrics-addr=0 \
--enable-ocp-cluster-monitoring=false \
--enable-ci-debug-output=true \
--private-platform=AWS \
--enable-ci-debug-output=true \
--oidc-storage-provider-s3-credentials "${AWSCREDS}" \
--oidc-storage-provider-s3-region "${REGION}" \
--oidc-storage-provider-s3-bucket-name "${BUCKET_NAME}" \
--control-plane-operator-image=quay.io/hypershift/hypershift:latest

0 comments on commit cc1aa3c

Please sign in to comment.