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

Implement DSCInitialization Controller #249

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
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -52,3 +52,6 @@ components/gcp-click-to-deploy/src/user_config/**
**/reg_tmp
scripts/gke/build/**

odh-manifests/

cover.out
14 changes: 13 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,10 +1,13 @@
# Build the manager binary
ARG GOLANG_VERSION=1.18.9

FROM registry.access.redhat.com/ubi8/go-toolset:$GOLANG_VERSION as builder
ARG LOCAL_BUNDLE=odh-manifests

WORKDIR /workspace
USER root
# Copy the Go Modules manifests
ENV BUNDLE=$LOCAL_BUNDLE
COPY go.mod go.mod
COPY go.sum go.sum
# cache deps before building and copying source so that we don't need to re-download as much
Expand All @@ -15,6 +18,10 @@ RUN go mod download
COPY main.go main.go
COPY apis/ apis/
COPY controllers/ controllers/
COPY pkg/ pkg/

# Add in the odh-manifests tarball
COPY $BUNDLE/ /opt/odh-manifests/

# Build
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
Expand All @@ -23,6 +30,11 @@ RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -a -o manager main.go
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
WORKDIR /
COPY --from=builder /workspace/manager .
USER 65532:65532
COPY --from=builder /opt/odh-manifests /opt/odh-manifests

RUN chown -R 1001:0 /opt/odh-manifests &&\
chmod -R a+r /opt/odh-manifests

USER 1001

ENTRYPOINT ["/manager"]
27 changes: 26 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ VERSION ?= 0.0.1
IMG ?= quay.io/vhire/opendatahub-operator:dev-$(VERSION)
IMAGE_BUILDER ?= podman
OPERATOR_NAMESPACE ?= opendatahub-operator-system
MANIFEST_REPO ?= opendatahub-io
MANIFEST_RELEASE ?= master
CHANNELS="stable,rolling"
DEFAULT_CHANNEL="rolling"

Expand Down Expand Up @@ -122,7 +124,7 @@ run: manifests generate fmt vet ## Run a controller from your host.
go run ./main.go

.PHONY: docker-build
docker-build: test ## Build docker image with the manager.
docker-build: test odh-manifests/version.py ## Build docker image with the manager.
${IMAGE_BUILDER} build -t ${IMG} .

.PHONY: docker-push
Expand All @@ -132,6 +134,15 @@ docker-push: ## Push docker image with the manager.
.PHONY: image
image: docker-build docker-push ## Build and push docker image with the manager.

MANIFESTS_TARBALL_URL="https://github.com/${MANIFEST_REPO}/odh-manifests/tarball/${MANIFEST_RELEASE}"

.PHONY: get-manifests
get-manifests: odh-manifests/version.py ## Get latest odh-manifests tarball

odh-manifests/version.py: ## Get latest odh-manifests tarball
rm -fr odh-manifests && mkdir odh-manifests
wget -c $(MANIFESTS_TARBALL_URL) -O - | tar -zxv -C odh-manifests/ --strip-components 1

##@ Deployment

ifndef ignore-not-found
Expand Down Expand Up @@ -242,3 +253,17 @@ catalog-build: opm ## Build a catalog image.
.PHONY: catalog-push
catalog-push: ## Push a catalog image.
$(MAKE) docker-push IMG=$(CATALOG_IMG)

TOOLBOX_GOLANG_VERSION := 1.18.9
TOOLBOX_OPERATOR_SDK_VERSION := 1.24.1

# Generate a Toolbox container for locally testing changes easily
.PHONY: toolbox
toolbox: ## Create a toolbox instance with the proper Golang and Operator SDK versions
$(IMAGE_BUILDER) build \
--build-arg GOLANG_VERSION=$(TOOLBOX_GOLANG_VERSION) \
--build-arg OPERATOR_SDK_VERSION=$(TOOLBOX_OPERATOR_SDK_VERSION) \
-f toolbox.Dockerfile -t opendatahub-toolbox .
$(IMAGE_BUILDER) stop opendatahub-toolbox ||:
toolbox rm opendatahub-toolbox ||:
toolbox create opendatahub-toolbox --image localhost/opendatahub-toolbox:latest
14 changes: 9 additions & 5 deletions apis/dscinitialization/v1alpha1/dscinitialization_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// List of constants to show different different reconciliation messages and statuses.
// List of constants to show different reconciliation messages and statuses.
const (
ReconcileFailed = "ReconcileFailed"
ReconcileInit = "ReconcileInit"
Expand All @@ -32,11 +32,14 @@ const (

// DSCInitializationSpec defines the desired state of DSCInitialization
type DSCInitializationSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file
Namespaces []string `json:"namespaces"`
Monitoring Monitoring `json:"monitoring,omitempty"`
ManifestsUri string `json:"manifestsUri,omitempty"`
}

// Foo is an example field of DSCInitialization. Edit dscinitialization_types.go to remove/update
Foo string `json:"foo,omitempty"`
type Monitoring struct {
Enabled bool `json:"enabled,omitempty"`
Namespace string `json:"namespace"`
}

// DSCInitializationStatus defines the observed state of DSCInitialization
Expand All @@ -59,6 +62,7 @@ type DSCInitializationStatus struct {
}

//+kubebuilder:object:root=true
//+kubebuilder:resource:scope=Cluster
//+kubebuilder:subresource:status
//+kubebuilder:printcolumn:name="Age",type=date,JSONPath=.metadata.creationTimestamp
//+kubebuilder:printcolumn:name="Phase",type=string,JSONPath=.status.phase,description="Current Phase"
Expand Down
23 changes: 22 additions & 1 deletion apis/dscinitialization/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions bundle.Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ LABEL operators.operatorframework.io.metrics.builder=operator-sdk-v1.24.1
LABEL operators.operatorframework.io.metrics.mediatype.v1=metrics+v1
LABEL operators.operatorframework.io.metrics.project_layout=go.kubebuilder.io/v3

# Labels for testing.
LABEL operators.operatorframework.io.test.mediatype.v1=scorecard+v1
LABEL operators.operatorframework.io.test.config.v1=tests/scorecard/

# Copy files to locations specified by labels.
COPY bundle/manifests /manifests/
COPY bundle/metadata /metadata/
COPY bundle/tests/scorecard /tests/scorecard/
Loading