Skip to content

Commit

Permalink
chore(build+manifests): Update how we get build deps in Makefile and …
Browse files Browse the repository at this point in the history
…bump operator (#61)

* chore(makefile): Update how we get build deps

* chore(config): bump operator-sdk->v1.22.2

After bumping the operator-sdk binary, needed to update the manager.yaml
and images.go to use `RELATED_IMAGE_` prefix for our images. Also run
`make bundle` to get updated manifests.
  • Loading branch information
djzager authored Jul 26, 2022
1 parent ebd6f47 commit 07cdc69
Show file tree
Hide file tree
Showing 9 changed files with 66 additions and 69 deletions.
54 changes: 30 additions & 24 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -136,34 +136,40 @@ deploy: manifests kustomize clustertasks ## Deploy controller to the K8s cluster
undeploy: ## Undeploy controller from the K8s cluster specified in ~/.kube/config. Call with ignore-not-found=true to ignore resource not found errors during deletion.
$(KUSTOMIZE) build config/default | kubectl delete --ignore-not-found=$(ignore-not-found) -f -

CONTROLLER_GEN = $(shell pwd)/bin/controller-gen
.PHONY: controller-gen
controller-gen: ## Download controller-gen locally if necessary.
$(call go-get-tool,$(CONTROLLER_GEN),sigs.k8s.io/controller-tools/cmd/controller-gen@v0.7.0)
##@ Build Dependencies

## Location to install dependencies to
LOCALBIN ?= $(shell pwd)/bin
$(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
KUSTOMIZE ?= $(LOCALBIN)/kustomize
CONTROLLER_GEN ?= $(LOCALBIN)/controller-gen
ENVTEST ?= $(LOCALBIN)/setup-envtest

## Tool Versions
KUSTOMIZE_VERSION ?= v3.8.7
CONTROLLER_TOOLS_VERSION ?= v0.9.0

KUSTOMIZE = $(shell pwd)/bin/kustomize

KUSTOMIZE_INSTALL_SCRIPT ?= "https://raw.githubusercontent.com/kubernetes-sigs/kustomize/master/hack/install_kustomize.sh"
.PHONY: kustomize
kustomize: ## Download kustomize locally if necessary.
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v3@v3.8.7)
kustomize: $(KUSTOMIZE) ## Download kustomize locally if necessary.
$(KUSTOMIZE): $(LOCALBIN)
test -s $(LOCALBIN)/kustomize || { curl -s $(KUSTOMIZE_INSTALL_SCRIPT) | bash -s -- $(subst v,,$(KUSTOMIZE_VERSION)) $(LOCALBIN); }

.PHONY: controller-gen
controller-gen: $(CONTROLLER_GEN) ## Download controller-gen locally if necessary.
$(CONTROLLER_GEN): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-tools/cmd/controller-gen@$(CONTROLLER_TOOLS_VERSION)

ENVTEST = $(shell pwd)/bin/setup-envtest
.PHONY: envtest
envtest: ## Download envtest-setup locally if necessary.
$(call go-get-tool,$(ENVTEST),sigs.k8s.io/controller-runtime/tools/setup-envtest@latest)

# go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool
@[ -f $(1) ] || { \
set -e ;\
TMP_DIR=$$(mktemp -d) ;\
cd $$TMP_DIR ;\
go mod init tmp ;\
echo "Downloading $(2)" ;\
GOBIN=$(PROJECT_DIR)/bin go get $(2) ;\
rm -rf $$TMP_DIR ;\
}
endef
envtest: $(ENVTEST) ## Download envtest-setup locally if necessary.
$(ENVTEST): $(LOCALBIN)
GOBIN=$(LOCALBIN) go install sigs.k8s.io/controller-runtime/tools/setup-envtest@latest

##@ OLM Stuff

.PHONY: bundle
bundle: manifests kustomize ## Generate bundle manifests and metadata, then validate generated files.
Expand Down
2 changes: 1 addition & 1 deletion bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ LABEL operators.operatorframework.io.bundle.manifests.v1=manifests/
LABEL operators.operatorframework.io.bundle.metadata.v1=metadata/
LABEL operators.operatorframework.io.bundle.package.v1=crane-operator
LABEL operators.operatorframework.io.bundle.channels.v1=alpha
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.15.0+git
LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.22.2
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

Expand Down
18 changes: 10 additions & 8 deletions bundle/manifests/crane-operator.clusterserviceversion.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ metadata:
console.openshift.io/plugins: '["crane-ui-plugin"]'
containerImage: quay.io/konveyor/crane-operator-container:latest
operatorframework.io/suggested-namespace: openshift-migration-toolkit
operators.operatorframework.io/builder: operator-sdk-v1.15.0+git
operators.operatorframework.io/builder: operator-sdk-v1.22.2
operators.operatorframework.io/project_layout: go.kubebuilder.io/v3
repository: https://github.com/konveyor/crane-operator
support: Red Hat
Expand Down Expand Up @@ -107,7 +107,9 @@ spec:
- get
serviceAccountName: proxy
deployments:
- name: crane-operator-controller-manager
- label:
control-plane: controller-manager
name: crane-operator-controller-manager
spec:
replicas: 1
selector:
Expand Down Expand Up @@ -146,13 +148,13 @@ spec:
command:
- /manager
env:
- name: CRANE_RUNNER_IMAGE
- name: RELATED_IMAGE_CRANE_RUNNER
value: quay.io/konveyor/crane-runner:latest
- name: CRANE_UI_PLUGIN_IMAGE
- name: RELATED_IMAGE_CRANE_UI_PLUGIN
value: quay.io/konveyor/crane-ui-plugin:latest
- name: CRANE_REVERSE_PROXY_IMAGE
- name: RELATED_IMAGE_CRANE_REVERSE_PROXY
value: quay.io/konveyor/crane-reverse-proxy:latest
- name: CRANE_SECRET_SERVICE_IMAGE
- name: RELATED_IMAGE_CRANE_SECRET_SERVICE
value: quay.io/konveyor/crane-secret-service:latest
image: quay.io/konveyor/crane-operator-container:latest
imagePullPolicy: Always
Expand Down Expand Up @@ -288,8 +290,8 @@ spec:
name: crane-runner
- image: quay.io/konveyor/crane-ui-plugin:latest
name: crane-ui-plugin
- image: quay.io/konveyor/crane-secret-service:latest
name: crane-secret-service
- image: quay.io/konveyor/crane-reverse-proxy:latest
name: crane-reverse-proxy
- image: quay.io/konveyor/crane-secret-service:latest
name: crane-secret-service
version: 99.0.0
19 changes: 9 additions & 10 deletions bundle/manifests/crane.konveyor.io_operatorconfigs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.7.0
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
name: operatorconfigs.crane.konveyor.io
spec:
Expand Down Expand Up @@ -43,13 +43,12 @@ spec:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are:
\"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type
\ // +patchStrategy=merge // +listType=map // +listMapKey=type
\ Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
\n // other fields }"
type FooStatus struct{ // Represents the observations of a foo's
current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
Expand Down Expand Up @@ -119,5 +118,5 @@ status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
conditions: null
storedVersions: null
2 changes: 1 addition & 1 deletion bundle/metadata/annotations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ annotations:
operators.operatorframework.io.bundle.metadata.v1: metadata/
operators.operatorframework.io.bundle.package.v1: crane-operator
operators.operatorframework.io.bundle.channels.v1: alpha
operators.operatorframework.io.metrics.builder: operator-sdk-v1.15.0+git
operators.operatorframework.io.metrics.builder: operator-sdk-v1.22.2
operators.operatorframework.io.metrics.mediatype.v1: metrics+v1
operators.operatorframework.io.metrics.project_layout: go.kubebuilder.io/v3

Expand Down
22 changes: 7 additions & 15 deletions config/crd/bases/crane.konveyor.io_operatorconfigs.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@

---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.7.0
controller-gen.kubebuilder.io/version: v0.9.0
creationTimestamp: null
name: operatorconfigs.crane.konveyor.io
spec:
Expand Down Expand Up @@ -45,13 +44,12 @@ spec:
description: "Condition contains details for one aspect of the current
state of this API Resource. --- This struct is intended for direct
use as an array at the field path .status.conditions. For example,
type FooStatus struct{ // Represents the observations of a
foo's current state. // Known .status.conditions.type are:
\"Available\", \"Progressing\", and \"Degraded\" // +patchMergeKey=type
\ // +patchStrategy=merge // +listType=map // +listMapKey=type
\ Conditions []metav1.Condition `json:\"conditions,omitempty\"
patchStrategy:\"merge\" patchMergeKey:\"type\" protobuf:\"bytes,1,rep,name=conditions\"`
\n // other fields }"
type FooStatus struct{ // Represents the observations of a foo's
current state. // Known .status.conditions.type are: \"Available\",
\"Progressing\", and \"Degraded\" // +patchMergeKey=type // +patchStrategy=merge
// +listType=map // +listMapKey=type Conditions []metav1.Condition
`json:\"conditions,omitempty\" patchStrategy:\"merge\" patchMergeKey:\"type\"
protobuf:\"bytes,1,rep,name=conditions\"` \n // other fields }"
properties:
lastTransitionTime:
description: lastTransitionTime is the last time the condition
Expand Down Expand Up @@ -117,9 +115,3 @@ spec:
storage: true
subresources:
status: {}
status:
acceptedNames:
kind: ""
plural: ""
conditions: []
storedVersions: []
8 changes: 4 additions & 4 deletions config/manager/manager.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ spec:
imagePullPolicy: Always
name: manager
env:
- name: CRANE_RUNNER_IMAGE
- name: RELATED_IMAGE_CRANE_RUNNER
value: quay.io/konveyor/crane-runner:latest
- name: CRANE_UI_PLUGIN_IMAGE
- name: RELATED_IMAGE_CRANE_UI_PLUGIN
value: quay.io/konveyor/crane-ui-plugin:latest
- name: CRANE_REVERSE_PROXY_IMAGE
- name: RELATED_IMAGE_CRANE_REVERSE_PROXY
value: quay.io/konveyor/crane-reverse-proxy:latest
- name: CRANE_SECRET_SERVICE_IMAGE
- name: RELATED_IMAGE_CRANE_SECRET_SERVICE
value: quay.io/konveyor/crane-secret-service:latest
securityContext:
allowPrivilegeEscalation: false
Expand Down
2 changes: 0 additions & 2 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
Expand Down Expand Up @@ -56,7 +55,6 @@ rules:
- patch
- update
- watch

---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
Expand Down
8 changes: 4 additions & 4 deletions controllers/images.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,19 +23,19 @@ import (
type ImageFunction func() string

func CraneRunnerImage() string {
return getEnvVar("CRANE_RUNNER_IMAGE", "quay.io/konveyor/crane-runner:latest")
return getEnvVar("RELATED_IMAGE_CRANE_RUNNER", "quay.io/konveyor/crane-runner:latest")
}

func CraneUIPluginImage() string {
return getEnvVar("CRANE_UI_PLUGIN_IMAGE", "quay.io/konveyor/crane-ui-plugin:latest")
return getEnvVar("RELATED_IMAGE_CRANE_UI_PLUGIN", "quay.io/konveyor/crane-ui-plugin:latest")
}

func CraneReverseProxyImage() string {
return getEnvVar("CRANE_REVERSE_PROXY_IMAGE", "quay.io/konveyor/crane-reverse-proxy:latest")
return getEnvVar("RELATED_IMAGE_CRANE_REVERSE_PROXY", "quay.io/konveyor/crane-reverse-proxy:latest")
}

func CraneSecretServiceImage() string {
return getEnvVar("CRANE_SECRET_SERVICE_IMAGE", "quay.io/konveyor/crane-secret-service:latest")
return getEnvVar("RELATED_IMAGE_CRANE_SECRET_SERVICE", "quay.io/konveyor/crane-secret-service:latest")
}

func getEnvVar(key, def string) string {
Expand Down

0 comments on commit 07cdc69

Please sign in to comment.