Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
4 changes: 0 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,3 @@ tools/bin
.envrc

.kube

config/example-cluster/ssh-key
config/example-cluster/pull-secret
config/example-cluster/aws-creds
44 changes: 25 additions & 19 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,47 +5,53 @@

### Run the HyperShift Operator in a local process

1. Ensure the `KUBECONFIG` evnvironment variable points to a management cluster
1. Ensure the `KUBECONFIG` environment variable points to a management cluster
with no HyperShift installed yet.

2. Build HyperShift.

make build
$ make build

3. Install HyperShift with the operator deployment scaled to zero so that it
doesn't conflict with your local operator process.
3. 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.

make install PROFILE=development
$ bin/hypershift install --development

4. Run the HyperShift operator locally. Replace `IMAGE` with a custom image,
if desired. This image is used for the Control Plane Operator.
4. Run the HyperShift operator locally.

make run-local IMAGE=registry.ci.openshift.org/hypershift/hypershift
$ bin/hypershift-operator run

### Run a custom image using the production profile
### Install HyperShift with a custom image
Comment thread
ironcladlou marked this conversation as resolved.

1. Build and push a custom image build to your own repository.

make IMG=quay.io/my/hypershift:latest docker-build docker-push

2. Deploy the latest production version.
2. Install HyperShift using the custom image:

make install PROFILE=production
$ bin/hypershift install --hypershift-image quay.io/my/hypershift:latest

3. Reconfigure the HyperShift operator deployment to use your custom image.
This image will also be used for the control plane operator.

oc --namespace hypershift set image deployment/operator operator=quay.io/my/hypershift:latest

### Run the e2e tests
### Run the e2e tests with a compiled binary

1. Install HyperShift.
2. Run the tests.

make install PROFILE=production
$ make e2e
$ bin/test-e2e -v -args --ginkgo.v --ginkgo.trace \
--e2e.quick-start.aws-credentials-file /my/aws-credentials \
--e2e.quick-start.pull-secret-file /my/pull-secret \
--e2e.quick-start.ssh-key-file /my/public-ssh-key

### Run the e2e tests with the local source tree

1. Install HyperShift.
2. Run the tests.

make test-e2e
$ go test -tags e2e -v ./test/e2e -args --ginkgo.v --ginkgo.trace \
--e2e.quick-start.aws-credentials-file /my/aws-credentials \
--e2e.quick-start.pull-secret-file /my/pull-secret \
--e2e.quick-start.ssh-key-file /my/public-ssh-key

### Visualize the Go dependency tree

Expand Down
90 changes: 41 additions & 49 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@ DIR := ${CURDIR}

# Image URL to use all building/pushing image targets
IMG ?= hypershift:latest

# Produce CRDs that work back to Kubernetes 1.11 (no version conversion)
CRD_OPTIONS ?= "crd:trivialVersions=true"

# Runtime CLI to use for building and pushing images
RUNTIME ?= docker

Expand All @@ -14,102 +16,92 @@ GO_GCFLAGS ?= -gcflags=all='-N -l'
GO=GO111MODULE=on GOFLAGS=-mod=vendor go
GO_BUILD_RECIPE=CGO_ENABLED=0 $(GO) build $(GO_GCFLAGS)

# Kustomize overlay to use
PROFILE ?= production

EXAMPLE_NAMESPACE ?= hypershift

# 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
else
GOBIN=$(shell go env GOBIN)
endif

all: build manifests
all: build

build: hypershift-operator control-plane-operator hosted-cluster-config-operator
build: hypershift-operator control-plane-operator hosted-cluster-config-operator hypershift

verify: build fmt vet

# Generate code
generate:
# Generate Kube manifests (e.g. CRDs)
.PHONY: hypershift-operator-manifests
hypershift-operator-manifests:
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./..." output:crd:artifacts:config=cmd/install/assets/hypershift-operator

# Build hypershift-operator binary
.PHONY: hypershift-operator
hypershift-operator:
$(BINDATA) -mode 420 -modtime 1 -pkg assets \
-o ./hypershift-operator/controllers/hostedcluster/assets/bindata.go \
--prefix hypershift-operator/controllers/hostedcluster/assets \
--ignore bindata.go \
--ignore '.*\.go' \
./hypershift-operator/controllers/hostedcluster/assets/...
gofmt -s -w ./hypershift-operator/controllers/hostedcluster/assets/bindata.go

$(GO_BUILD_RECIPE) -o bin/hypershift-operator ./hypershift-operator

.PHONY: control-plane-operator
control-plane-operator:
$(BINDATA) -mode 420 -modtime 1 -pkg assets \
-o ./control-plane-operator/controllers/hostedcontrolplane/assets/bindata.go \
--prefix control-plane-operator/controllers/hostedcontrolplane/assets \
--ignore bindata.go \
--ignore '.*\.go' \
./control-plane-operator/controllers/hostedcontrolplane/assets/...

gofmt -s -w ./hypershift-operator/controllers/hostedcluster/assets/bindata.go
gofmt -s -w ./control-plane-operator/controllers/hostedcontrolplane/assets/bindata.go

$(CONTROLLER_GEN) object:headerFile="hack/boilerplate.go.txt" paths="./..."

# Build hypershift-operator binary
hypershift-operator: generate
$(GO_BUILD_RECIPE) -o bin/hypershift-operator ./hypershift-operator

control-plane-operator: generate
$(GO_BUILD_RECIPE) -o bin/control-plane-operator ./control-plane-operator

# Build hosted-cluster-config-operator binary
hosted-cluster-config-operator: generate
.PHONY: hosted-cluster-config-operator
hosted-cluster-config-operator:
$(GO_BUILD_RECIPE) -o bin/hosted-cluster-config-operator ./hosted-cluster-config-operator

.PHONY: hypershift
hypershift:
$(BINDATA) -mode 420 -modtime 1 -pkg assets \
-o ./cmd/install/assets/bindata.go \
--prefix cmd/install/assets \
--ignore '.*\.go' \
./cmd/install/assets/...
gofmt -s -w ./cmd/install/assets/bindata.go

$(GO_BUILD_RECIPE) -o bin/hypershift .

# Run tests
.PHONY: test
test: build
$(GO) test ./... -coverprofile cover.out

# Generate Kube manifests (e.g. CRDs)
manifests:
$(CONTROLLER_GEN) $(CRD_OPTIONS) paths="./..." output:crd:artifacts:config=config/hypershift-operator

# Installs hypershift into a cluster
install: manifests
kustomize build config/install/$(PROFILE) | oc apply -f -

# Uninstalls hypershit from a cluster
uninstall: manifests
kustomize build config/install/$(PROFILE) | oc delete -f -

# Builds the config with Kustomize for manual usage
.PHONY: config
config:
kustomize build config/install/$(PROFILE)
.PHONY: e2e
e2e:
$(GO) test -tags e2e -c -o bin/test-e2e ./test/e2e

# Run go fmt against code
.PHONY: fmt
fmt:
$(GO) fmt ./...

# Run go vet against code
.PHONY: vet
vet:
$(GO) vet ./...

# Build the docker image
.PHONY: docker-build
docker-build:
${RUNTIME} build . -t ${IMG}

# Push the docker image
.PHONY: docker-push
docker-push:
${RUNTIME} push ${IMG}

.PHONY: run-local
run-local:
bin/hypershift-operator run --operator-image=$(IMAGE)

BUILD_EXAMPLE_CLUSTER=KUSTOMIZE_PLUGIN_HOME=$(DIR)/config/example-cluster/plugin kustomize build --enable_alpha_plugins ./config/example-cluster

example-cluster:
$(BUILD_EXAMPLE_CLUSTER)

install-example-cluster:
$(BUILD_EXAMPLE_CLUSTER) | oc apply --namespace $(EXAMPLE_NAMESPACE) -f -

.PHONY: test-e2e
test-e2e: ## Run the e2e tests
$(MAKE) -C test/e2e run
35 changes: 17 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,40 +6,39 @@ Guest clustering for [OpenShift](https://openshift.io).

* Admin access to an OpenShift cluster (version 4.7).
* The OpenShift `oc` CLI tool.
* [Kustomize](https://kustomize.io)
* The `hypershift` CLI tool:

### Installation
$ make hypershift

### Install HyperShift

Install HyperShift into the management cluster:

```bash
$ make install
$ bin/hypershift install
```

Remove HyperShift from the management cluster:

```bash
$ make uninstall
$ bin/hypershift install --render | oc delete -f -
```

### Create a cluster
### Create an example cluster

First, create the following files containing secrets used by the example cluster:
Prerequisites:

- `config/example-cluster/pull-secret` a valid pull secret for image pulls.
- `config/example-cluster/ssh-key` an SSH public key for guest node access.
- `config/example-cluster/aws-creds` an [aws credentials file](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html).
- A valid pull secret file for image pulls.
- An SSH public key file for guest node access.
- An [aws credentials file](https://docs.aws.amazon.com/cli/latest/userguide/cli-configure-files.html).

Install the example cluster:

```bash
$ make install-example-cluster
```

If you want to see but not apply the example cluster resource (i.e. dry run), try:

```bash
$ make example-cluster
$ bin/hypershift create cluster \
--pull-secret /my/pull-secret \
--aws-creds /my/aws-credentials \
--ssh-key /my/ssh-public-key
```

When the cluster is available, get the guest kubeconfig using:
Expand All @@ -54,7 +53,7 @@ To create additional node pools, create a resource like:
apiVersion: hypershift.openshift.io/v1alpha1
kind: NodePool
metadata:
namespace: hypershift
namespace: clusters
name: example-extended
spec:
clusterName: example
Expand All @@ -70,5 +69,5 @@ spec:
And delete the cluster using:

```bash
$ oc delete --namespace hypershift hostedclusters/example
$ oc delete --namespace clusters
```
Loading