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

Allow updating of resources managed by operator #126

Closed
wants to merge 3 commits into from
Closed
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
22 changes: 6 additions & 16 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -148,29 +148,19 @@ build-kfctl-tgz: build-kfctl
build-and-push-operator: build-operator push-operator
build-push-update-operator: build-operator push-operator update-operator-image

# Build operator image
build-operator:
prep-build-operator:
go mod vendor
# Fix duplicated logrus library (Sirupsen/logrus and sirupsen/logrus) bug
# due to the two different logrus versions that kfctl is using.
pushd vendor/github.com/Sirupsen/logrus/ && \
echo '\
// +build linux aix\n\
package logrus\n\
import "golang.org/x/sys/unix"\n\
func isTerminal(fd int) bool {\n\
_, err := unix.IoctlGetTermios(fd, unix.TCGETS)\n\
return err == nil\n\
} ' > terminal_check_unix.go && \
popd

# Build operator image
build-operator: prep-build-operator
ifneq ($(DOCKERFILE), Dockerfile)
pushd build &&\
cp Dockerfile Dockerfile.bckp &&\
cp ${DOCKERFILE} Dockerfile &&\
popd
endif
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 ${GO} build -a -o build/_output/bin/$(OPERATOR_BINARY_NAME) cmd/manager/main.go
${IMAGE_BUILDER} build build -t ${OPERATOR_IMG}

${IMAGE_BUILDER} build . -f build/Dockerfile -t ${OPERATOR_IMG}
ifneq ($(DOCKERFILE), Dockerfile)
pushd build &&\
cp Dockerfile.bckp Dockerfile &&\
Expand Down
38 changes: 19 additions & 19 deletions build/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,28 @@
ARG binary_name=kfctl
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest AS build
FROM docker.io/openshift/origin-release:golang-1.13 AS build
ARG binary_name

ENV OPERATOR=/usr/local/bin/${binary_name} \
USER_UID=1001 \
USER_NAME=kfctl \
HOMEDIR=/homedir
COPY . /opt/kfctl
WORKDIR /opt/kfctl/

# install operator binary
COPY _output/bin/${binary_name} ${OPERATOR}
RUN GOOS=linux GOARCH=amd64 go build --trimpath -a -o build/_output/bin/${binary_name} -ldflags="-X 'github.com/kubeflow/kfctl/v3/pkg/kfapp/kustomize.enableKustAlphaPlugin=yes'" cmd/manager/main.go
RUN cd kustomize-fns/v1alpha1/applyresources && go mod vendor && \
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build --trimpath --mod=vendor --buildmode=plugin -o /opt/kfctl/build/_output/plugins/v1alpha1/applyresources/ApplyResources.so ApplyResources.go

COPY bin /usr/local/bin
RUN /usr/local/bin/user_setup
RUN /usr/local/bin/entrypoint
FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
ARG binary_name
ENV OPERATOR=/usr/local/bin/${binary_name}\
HOME=/opt/${binary_name}

FROM gcr.io/distroless/base-debian10
ENV OPERATOR=/usr/local/bin/${binary_name} \
USER_UID=1001 \
USER_NAME=kfctl \
HOMEDIR=/homedir
RUN mkdir -p ${HOME} &&\
chown 1001:0 ${HOME} &&\
chmod ug+rwx ${HOME}

COPY --from=build /usr/local/bin/${binary_name} ${OPERATOR}
COPY --from=build /etc/passwd /etc/passwd
COPY --from=build ${HOMEDIR} ${HOME}
WORKDIR ${HOME}

COPY --from=build /opt/kfctl/build/_output/bin/${binary_name} ${OPERATOR}
COPY --from=build /opt/kfctl/build/_output/plugins/ $HOME/.config/kustomize/plugin/

ENTRYPOINT ["${OPERATOR}"]

USER ${USER_UID}
USER 1001
5 changes: 1 addition & 4 deletions build/Dockerfile.multistage
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@ USER root
WORKDIR /scratch
COPY . .

# Rather than echo the contents of terminal_check_unit.go as in the Makefile, we just copy it since the
# file in sirupsen is essentially identical to what is being generated. If that changes, so will this.
RUN go mod vendor &&\
cp vendor/github.com/sirupsen/logrus/terminal_check_unix.go vendor/github.com/Sirupsen/logrus/terminal_check_unix.go
RUN go mod vendor

RUN go build -o build/_output/bin/kfctl -gcflags all=-trimpath=/scratch -asmflags all=-trimpath=/scratch -mod=vendor github.com/kubeflow/kfctl/v3/cmd/manager

Expand Down
14 changes: 13 additions & 1 deletion build/Dockerfile.ubi
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
ARG binary_name=kfctl
FROM registry.access.redhat.com/ubi8/go-toolset:latest AS build
ARG binary_name

COPY . /opt/kfctl
WORKDIR /opt/kfctl/

RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -a -o build/_output/bin/${binary_name} -ldflags="-X 'github.com/kubeflow/kfctl/v3/pkg/kfapp/kustomize.enableKustAlphaPlugin=yes'" cmd/manager/main.go
RUN cd kustomize-fns/v1alpha1/applyresources && go mod vendor &&\
CGO_ENABLED=1 GOOS=linux GOARCH=amd64 go build -buildmode plugin -o /opt/kfctl/build/_output/plugins/v1alpha1/applyresources/ApplyResources.so ApplyResources.go

FROM registry.access.redhat.com/ubi8/ubi-minimal:latest
ARG binary_name
ENV OPERATOR=/usr/local/bin/${binary_name}\
HOME=/opt/${binary_name}

Expand All @@ -9,7 +20,8 @@ RUN mkdir -p ${HOME} &&\

WORKDIR ${HOME}

COPY _output/bin/${binary_name} ${OPERATOR}
COPY --from=build /opt/kfctl/build/_output/bin/${binary_name} ${OPERATOR}
COPY --from=build /opt/kfctl/build/_output/plugins/ $HOME/.config/kustomize/plugin/

ENTRYPOINT ["${OPERATOR}"]

Expand Down
16 changes: 16 additions & 0 deletions bundle/manifests/default_plugins_configmap.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: default-plugins
data:
applyResources.yaml: |-
apiVersion: v1alpha1
kind: ApplyResources
metadata:
name: myTransformer
spec:
fieldSpecs:
- kind: Secret
version: v1
- kind: ConfigMap
version: v1
2 changes: 1 addition & 1 deletion cmd/kfctl/cmd/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ func init() {
string(kftypes.DUMP)+" manifests to stdout, default is false")
bindErr = buildCfg.BindPFlag(string(kftypes.DUMP), buildCmd.Flags().Lookup(string(kftypes.DUMP)))
if bindErr != nil {
log.Errorf("Couldn't set flag --%v: %v", string(kftypes.VERBOSE), bindErr)
log.Errorf("Couldn't set flag --%v: %v", string(kftypes.DUMP), bindErr)
return
}
}
11 changes: 11 additions & 0 deletions deploy/operator.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,14 @@ spec:
valueFrom:
fieldRef:
fieldPath: metadata.name
volumeMounts:
- mountPath: /opt/kfctl/default-plugins
name: default-plugins
readOnly: true
volumes:
- name: default-plugins
configMap:
name: default-plugins
items:
- key: applyResources.yaml
path: applyResources.yaml
16 changes: 7 additions & 9 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ require (
cloud.google.com/go v0.57.0
github.com/Azure/go-autorest v13.3.3+incompatible // indirect
github.com/MakeNowJust/heredoc v1.0.0 // indirect
github.com/Sirupsen/logrus v0.0.0-00010101000000-000000000000 // indirect
github.com/aws/aws-sdk-go v1.27.1
github.com/cenkalti/backoff v2.2.1+incompatible
github.com/chai2010/gettext-go v0.0.0-20170215093142-bf70f2a70fb1 // indirect
Expand All @@ -15,7 +14,6 @@ require (
github.com/elazarl/goproxy/ext v0.0.0-20190711103511-473e67f1d7d2 // indirect
github.com/fatih/color v1.7.0
github.com/ghodss/yaml v1.0.1-0.20190212211648-25d852aebe32
github.com/go-openapi/spec v0.19.5 // indirect
github.com/go-yaml/yaml v2.1.0+incompatible
github.com/gogo/protobuf v1.3.1
github.com/golangplus/testing v0.0.0-20180327235837-af21d9c3145e
Expand All @@ -25,14 +23,15 @@ require (
github.com/hashicorp/go-version v1.2.0
github.com/imdario/mergo v0.3.8
github.com/jlewi/cloud-endpoints-controller v0.0.0-20200604211613-aff0aaad5602
github.com/kubeflow/kfctl/kustomize-fns v0.0.0-20210315162347-b53bbfd2bbfc // indirect
github.com/kubernetes-sigs/application v0.8.0
github.com/onrik/logrus v0.5.1
github.com/operator-framework/operator-lifecycle-manager v0.0.0-20191115003340-16619cd27fa5
github.com/operator-framework/operator-sdk v0.13.0
github.com/otiai10/copy v1.0.2
github.com/pkg/errors v0.8.1
github.com/prometheus/common v0.7.0
github.com/sirupsen/logrus v1.6.0
github.com/sirupsen/logrus v1.8.1
github.com/spf13/cobra v1.0.0
github.com/spf13/pflag v1.0.5
github.com/spf13/viper v1.4.0
Expand All @@ -43,26 +42,25 @@ require (
golang.org/x/crypto v0.0.0
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5
golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d
golang.org/x/sys v0.0.0-20210503173754-0981d6026fa6 // indirect
google.golang.org/api v0.25.0
google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84
gopkg.in/airbrake/gobrake.v2 v2.0.9 // indirect
gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 // indirect
gopkg.in/gemnasium/logrus-airbrake-hook.v2 v2.1.2 // indirect
gopkg.in/yaml.v2 v2.2.8
k8s.io/api v0.17.0
k8s.io/apiextensions-apiserver v0.0.0
k8s.io/apimachinery v0.17.1
k8s.io/apimachinery v0.18.3
k8s.io/cli-runtime v0.0.0
k8s.io/client-go v12.0.0+incompatible
k8s.io/kubernetes v1.16.2
sigs.k8s.io/controller-runtime v0.4.0
sigs.k8s.io/kustomize/v3 v3.2.0
sigs.k8s.io/yaml v1.1.0
sigs.k8s.io/yaml v1.2.0
)

replace (
git.apache.org/thrift.git => github.com/apache/thrift v0.0.0-20180902110319-2566ecd5d999
github.com/Sirupsen/logrus => github.com/sirupsen/logrus v1.0.5
// this is required to get rid of github.com/Sirupsen/logrus module
github.com/docker/docker => github.com/docker/engine v17.12.0-ce-rc1.0.20190717161051-705d9623b7c1+incompatible
github.com/go-openapi/jsonpointer => github.com/go-openapi/jsonpointer v0.17.0
github.com/go-openapi/jsonreference => github.com/go-openapi/jsonreference v0.17.0
github.com/go-openapi/spec => github.com/go-openapi/spec v0.18.0
Expand Down
Loading