Skip to content
Merged
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
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ WORKDIR /hypershift

COPY . .
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o bin/hypershift-operator hypershift-operator/main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o bin/control-plane-operator control-plane-operator/main.go
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -o bin/hosted-cluster-config-operator hosted-cluster-config-operator/main.go

FROM quay.io/openshift/origin-base:4.6
COPY --from=builder /hypershift/bin/hypershift-operator /usr/bin/hypershift-operator
COPY --from=builder /hypershift/bin/control-plane-operator /usr/bin/control-plane-operator
COPY --from=builder /hypershift/bin/hosted-cluster-config-operator /usr/bin/hosted-cluster-config-operator
15 changes: 8 additions & 7 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
## Development How-to Guides


### Run the operator in a local process
### Run the HyperShift Operator in a local process

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

2. Build HyperShift.

Expand All @@ -16,11 +17,12 @@

make install PROFILE=development

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

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

### Run custom operator images
### Run a custom image using the production profile

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

Expand All @@ -31,8 +33,7 @@
make install PROFILE=production

3. Reconfigure the HyperShift operator deployment to use your custom image.
This will also cause the image you specify to be used for the hosted cluster
config operator as well.
This image will also be used for the control plane operator.

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

Expand Down
28 changes: 20 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ 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
Expand All @@ -26,26 +28,36 @@ endif

all: build manifests

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

verify: build fmt vet

# Generate code
generate:
$(BINDATA) -mode 420 -modtime 1 -pkg hypershift \
-o ./hypershift-operator/assets/controlplane/hypershift/bindata.go \
--prefix hypershift-operator/assets/controlplane/hypershift \
$(BINDATA) -mode 420 -modtime 1 -pkg assets \
-o ./hypershift-operator/controllers/hostedcluster/assets/bindata.go \
--prefix hypershift-operator/controllers/hostedcluster/assets \
--ignore bindata.go \
./hypershift-operator/controllers/hostedcluster/assets/...

$(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 \
./hypershift-operator/assets/controlplane/hypershift/...
./control-plane-operator/controllers/hostedcontrolplane/assets/...

gofmt -s -w ./hypershift-operator/assets/controlplane/hypershift/bindata.go
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
$(GO_BUILD_RECIPE) -o bin/hosted-cluster-config-operator ./hosted-cluster-config-operator
Expand Down Expand Up @@ -88,15 +100,15 @@ docker-push:
${RUNTIME} push ${IMG}

run-local:
bin/hypershift-operator run
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 hypershift -f -
$(BUILD_EXAMPLE_CLUSTER) | oc apply --namespace $(EXAMPLE_NAMESPACE) -f -

.PHONY: test-e2e
test-e2e: ## Run the e2e tests
Expand Down
11 changes: 7 additions & 4 deletions config/hypershift-operator/operator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ spec:
- name: operator
image: hypershift:latest
imagePullPolicy: Always
command:
- /usr/bin/hypershift-operator
args:
- run
env:
- name: MY_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
command: [ "/usr/bin/hypershift-operator" ]
args: [ "run", "--namespace", "$(MY_NAMESPACE)", "--deployment-name", "operator" ]
Loading