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

(knative, kfserving, cert-manager) Build working solution for kfserving integration #212

Merged
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
71 changes: 52 additions & 19 deletions kubeflow/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -69,18 +69,9 @@ apply-kubeflow: validate-values check-name
kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/namespaces ./common/kubeflow-namespace
kubectl --context=$(KFCTXT) apply -f ./$(BUILD_DIR)/namespaces

# Kubeflow kubeflow-istio
rm -rf $(BUILD_DIR)/kubeflow-istio && mkdir -p $(BUILD_DIR)/kubeflow-istio
kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/kubeflow-istio ./common/istio
kubectl --context=$(KFCTXT) apply -f ./$(BUILD_DIR)/kubeflow-istio
$(MAKE) apply-istio

# Common cert-manager
rm -rf $(BUILD_DIR)/cert-manager && mkdir -p $(BUILD_DIR)/cert-manager
kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/cert-manager ./common/cert-manager
kubectl --context=$(KFCTXT) apply -f ./$(BUILD_DIR)/cert-manager
kubectl --context=$(KFCTXT) -n cert-manager wait --for=condition=Available --timeout=600s deploy cert-manager-webhook
kubectl --context=$(KFCTXT) -n cert-manager wait --for=condition=Available --timeout=600s deploy cert-manager
kubectl --context=$(KFCTXT) -n cert-manager wait --for=condition=Available --timeout=600s deploy cert-manager-cainjector
$(MAKE) apply-cert-manager

# Contrib metacontroller
rm -rf $(BUILD_DIR)/metacontroller && mkdir -p $(BUILD_DIR)/metacontroller
Expand Down Expand Up @@ -157,10 +148,9 @@ apply-kubeflow: validate-values check-name
kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/pipeline ./apps/pipeline
kubectl --context=$(KFCTXT) apply -f ./$(BUILD_DIR)/pipeline

# App kfserving
rm -rf $(BUILD_DIR)/kfserving && mkdir -p $(BUILD_DIR)/kfserving
kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/kfserving ./apps/kfserving
kubectl --context=$(KFCTXT) apply -f ./$(BUILD_DIR)/kfserving
$(MAKE) apply-knative

$(MAKE) apply-kfserving

# Common user-namespace
rm -rf $(BUILD_DIR)/user-namespace && mkdir -p $(BUILD_DIR)/user-namespace
Expand All @@ -172,10 +162,7 @@ apply-kubeflow: validate-values check-name
kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/katib ./apps/katib
kubectl --context=$(KFCTXT) apply -f ./$(BUILD_DIR)/katib

# Common cert-manager kubeflow-issuer
rm -rf $(BUILD_DIR)/kubeflow-issuer && mkdir -p $(BUILD_DIR)/kubeflow-issuer
kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/kubeflow-issuer ./common/cert-manager/upstream/cert-manager/kubeflow-issuer
kubectl --context=$(KFCTXT) apply -f ./$(BUILD_DIR)/kubeflow-issuer
$(MAKE) apply-kubeflow-issuer

# Kick the IAP pod because we will reset the policy and need to patch it.
# TODO(https://github.com/kubeflow/gcp-blueprints/issues/14)
Expand All @@ -184,6 +171,52 @@ apply-kubeflow: validate-values check-name
# https://github.com/kubeflow/gcp-blueprints/issues/160
kubectl --context=$(KFCTXT) -n istio-system delete pods -l service=backend-updater

.PHONY: apply-knative
apply-knative:
# Common Knative
# It has error when trying to patch the resource downloaded from knative because it doesn't match kustomize requirement.
# Original release of knative manifest can not be patched by kustomize because of `already registered id`. For now we run kubectl directly.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we create an issue to log this problem with a bit more details?

kubernetes-sigs/kustomize#1251

My understanding is that there are duplicate resources between several kustomize folders. Are we including them correctly? If yes, maybe we should file an upstream issue?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are 2 issues that I came across with regards to the knative manifests. The first is a bug in kustomize causing YAML anchors to not work properly. The second is that the serving-core.yaml contains all of the CRDs that are in the serving-crds.yaml file. As such, you can't use both when using Kustomize, but you might run into a chicken & egg so you need to apply the manifests twice if your not using something that continuously syncs like Argo CD.

I expanded the manifests to remove the YAML anchors and created the following kustomize folder for the Argo CD installation: argoflow/argoflow@ce115f0.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you Yuan and David for the suggestion! Indeed if I include both serving-crd.yaml and serving-core.yaml, it will fail with duplicated definition. However, I encountered another issue when using only serving-core.yaml. I created an issue in #217.

For the manifest expand which David has made, do you think it makes sense to upload this expanded serving-core.yaml to kubeflow/manifests repo? Otherwise every distribution needs to perform such change to a knative source file.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe a decision was made to not update KNative (or cert-manager for that matter) in the manifests repo before the 1.3 release. So I believe the route forward is to add these manifests in the gcp-blueprints repo directly for now, and try and get the fixes upstreamed after the release.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for clarifying, let's merge the fix in kubeflow/manifests after the release. We will do the patch for now on gcp-blueprints.

rm -rf $(BUILD_DIR)/knative && mkdir -p $(BUILD_DIR)/knative
kustomize build -o $(BUILD_DIR)/knative ./common/knative
kubectl --context=${KFCTXT} apply -f ./$(BUILD_DIR)/knative/*v1_namespace_knative-serving.yaml
kubectl --context=$(KFCTXT) apply --recursive=true -f ./$(BUILD_DIR)/knative

.PHONY: apply-kfserving
apply-kfserving:
# App kfserving
rm -rf $(BUILD_DIR)/kfserving && mkdir -p $(BUILD_DIR)/kfserving
kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/kfserving ./apps/kfserving
kubectl --context=$(KFCTXT) apply -f ./$(BUILD_DIR)/kfserving
kubectl --context=$(KFCTXT) patch cm config-domain --namespace knative-serving --type merge -p '{"data":{"$(NAME).endpoints.$(PROJECT).cloud.goog": ""}}'

.PHONY: apply-cert-manager
apply-cert-manager:
# Common cert-manager
rm -rf $(BUILD_DIR)/cert-manager && mkdir -p $(BUILD_DIR)/cert-manager
kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/cert-manager ./common/cert-manager
# Try kpt live apply to simplify this steps.
kubectl --context=$(KFCTXT) apply -f ./$(BUILD_DIR)/cert-manager/*v1_namespace_cert-manager.yaml
kubectl --context=$(KFCTXT) apply --recursive=true -f ./$(BUILD_DIR)/cert-manager
kubectl --context=$(KFCTXT) -n cert-manager wait --for=condition=Available --timeout=600s deploy cert-manager-webhook
kubectl --context=$(KFCTXT) -n cert-manager wait --for=condition=Available --timeout=600s deploy cert-manager
kubectl --context=$(KFCTXT) -n cert-manager wait --for=condition=Available --timeout=600s deploy cert-manager-cainjector

.PHONY: apply-kubeflow-issuer
apply-kubeflow-issuer:
# Common kubeflow-issuer for cert-manager
rm -rf $(BUILD_DIR)/kubeflow-issuer && mkdir -p $(BUILD_DIR)/kubeflow-issuer
kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/kubeflow-issuer ./common/cert-manager/cert-manager-1-3/cert-manager/kubeflow-issuer
# kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/kubeflow-issuer ./common/cert-manager/upstream/cert-manager/kubeflow-issuer
kubectl --context=$(KFCTXT) apply --recursive=true -f ./$(BUILD_DIR)/kubeflow-issuer


.PHONY: apply-istio
apply-istio:
# Kubeflow kubeflow-istio
rm -rf $(BUILD_DIR)/kubeflow-istio && mkdir -p $(BUILD_DIR)/kubeflow-istio
kustomize build --load-restrictor LoadRestrictionsNone -o $(BUILD_DIR)/kubeflow-istio ./common/istio
kubectl --context=$(KFCTXT) apply -f ./$(BUILD_DIR)/kubeflow-istio

.PHONY: apply-v2
apply-v2: clean-build check-name check-iap apply-gcp wait-gcp create-ctxt apply-asm iap-secret apply-kubeflow
ifeq ($(PRIVATE_GKE),true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization

resources:
- https://github.com/jetstack/cert-manager/releases/download/v1.3.0/cert-manager.yaml

images:
- name: quay.io/jetstack/cert-manager-controller
newName: quay.io/jetstack/cert-manager-controller
newTag: v1.3.0
- name: quay.io/jetstack/cert-manager-cainjector
newName: quay.io/jetstack/cert-manager-cainjector
newTag: v1.3.0
- name: quay.io/jetstack/cert-manager-webhook
newName: quay.io/jetstack/cert-manager-webhook
newTag: v1.3.0
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: kubeflow-self-signing-issuer
spec:
selfSigned: {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# Define the self-signed issuer for Kubeflow
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: cert-manager
commonLabels:
kustomize.component: cert-manager
app.kubernetes.io/component: cert-manager
app.kubernetes.io/name: cert-manager
resources:
- cluster-issuer.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
apiVersion: cert-manager.io/v1alpha2
kind: ClusterIssuer
metadata:
name: letsencrypt-prod
spec:
acme:
email: $(acmeEmail)
http01: {}
privateKeySecretRef:
name: letsencrypt-prod-secret
server: $(acmeUrl)
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../base
namespace: cert-manager
resources:
- cluster-issuer.yaml
commonLabels:
kustomize.component: cert-manager
app.kubernetes.io/component: cert-manager
app.kubernetes.io/name: cert-manager
configMapGenerator:
- name: cert-manager-parameters
behavior: merge
envs:
- params.env
generatorOptions:
disableNameSuffixHash: true
vars:
- name: acmeEmail
objref:
kind: ConfigMap
name: cert-manager-parameters
apiVersion: v1
fieldref:
fieldpath: data.acmeEmail
- name: acmeUrl
objref:
kind: ConfigMap
name: cert-manager-parameters
apiVersion: v1
fieldref:
fieldpath: data.acmeUrl
configurations:
- params.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
acmeEmail=
acmeUrl=https://acme-v02.api.letsencrypt.org/directory
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
varReference:
- path: spec/acme/email
kind: ClusterIssuer
- path: spec/acme/server
kind: ClusterIssuer
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# TODO(https://github.com/kubeflow/manifests/issues/1052) clean up
# the manifests after the refactor is done. We should move
# cluster-issuer into the kubeflow-issuer package.
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
bases:
- ../../base
resources:
- ../../kubeflow-issuer
commonLabels:
kustomize.component: cert-manager
app.kubernetes.io/component: cert-manager
app.kubernetes.io/name: cert-manager
7 changes: 4 additions & 3 deletions kubeflow/common/cert-manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
- ./application # {"$kpt-set":"cert-manager-cert-manager-v3"}
- ./upstream/cert-manager-crds/base
- ./upstream/cert-manager-kube-system-resources/base # {"$kpt-set":"cert-manager-cert-manager-kube-system-resources-base"}
# - ./application # {"$kpt-set":"cert-manager-cert-manager-v3"}
# - ./upstream/cert-manager-crds/base
# - ./upstream/cert-manager-kube-system-resources/base # {"$kpt-set":"cert-manager-cert-manager-kube-system-resources-base"}
- ./cert-manager-1-3/cert-manager/base
Loading