From 40714f325c70ebc5b6875aafbaed3fbaccbefe7f Mon Sep 17 00:00:00 2001 From: Yujun Zhang Date: Mon, 8 Jul 2019 13:58:59 +0800 Subject: [PATCH] BUG REPORT: failed to build on kustomize 3.0.0. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Observed: * It fails to patch object in base * It can patch object in resources * It works on bundled kustomize (v2.0.3) in kubectl v1.15 ``` ❯ kustomize version Version: {KustomizeVersion:3.0.0 GitCommit:e0bac6ad192f33d993f11206e24f6cda1d04c4ec BuildDate:2019-07-03T18:21:24Z GoOs:darwin GoArch:amd64} ❯ kustomize build examples/patches-no-matches Error: no matches for OriginalId extensions_v1beta1_Deployment|~X|k8s-sidecar-injector-prod; no matches for CurrentId extensions_v1beta1_Deployment|~X|k8s-sidecar-injector-prod; failed to find unique target for patch extensions_v1beta1_Deployment|k8s-sidecar-injector-prod ❯ kustomize build examples/patches-no-matches/base apiVersion: extensions/v1beta1 kind: Deployment ... ❯ kubectl version Client Version: version.Info{Major:"1", Minor:"15", GitVersion:"v1.15.0", GitCommit:"e8462b5b5dc2584fdcd18e6bcfe9f1e4d970a529", GitTreeState:"clean", BuildDate:"2019-06-20T04:49:16Z", GoVersion:"go1.12.6", Compiler:"gc", Platform:"darwin/amd64"} Server Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.6", GitCommit:"b1d75deca493a24a2f87eb1efde1a569e52fc8d9", GitTreeState:"clean", BuildDate:"2018-12-16T04:30:10Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"} ❯ kubectl kustomize examples/patches-no-matches apiVersion: extensions/v1beta1 kind: Deployment ... ``` --- .../patches-no-matches/base/deployment.yaml | 66 +++++++++++++++++++ .../base/kustomization.yaml | 4 ++ .../patches-no-matches/kustomization.yaml | 6 ++ examples/patches-no-matches/patches.yaml | 14 ++++ 4 files changed, 90 insertions(+) create mode 100644 examples/patches-no-matches/base/deployment.yaml create mode 100755 examples/patches-no-matches/base/kustomization.yaml create mode 100644 examples/patches-no-matches/kustomization.yaml create mode 100644 examples/patches-no-matches/patches.yaml diff --git a/examples/patches-no-matches/base/deployment.yaml b/examples/patches-no-matches/base/deployment.yaml new file mode 100644 index 0000000000..a562ed09fe --- /dev/null +++ b/examples/patches-no-matches/base/deployment.yaml @@ -0,0 +1,66 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: "k8s-sidecar-injector-prod" + namespace: "kube-system" + labels: + k8s-app: "k8s-sidecar-injector" + track: "prod" +spec: + replicas: 2 + strategy: + type: RollingUpdate + rollingUpdate: + maxSurge: 1 + maxUnavailable: 0 + template: + metadata: + labels: + k8s-app: "k8s-sidecar-injector" + track: "prod" + spec: + serviceAccountName: k8s-sidecar-injector + volumes: + - name: secrets + secret: + secretName: k8s-sidecar-injector + containers: + - name: "k8s-sidecar-injector" + imagePullPolicy: Always + image: tumblr/k8s-sidecar-injector:latest + command: ["entrypoint.sh"] + args: [] + ports: + - name: https + containerPort: 9443 + - name: http-metrics + containerPort: 9000 + volumeMounts: + - name: secrets + mountPath: /var/lib/secrets + livenessProbe: + httpGet: + scheme: HTTPS + path: /health + port: https + initialDelaySeconds: 10 + periodSeconds: 10 + timeoutSeconds: 3 + resources: + requests: + cpu: "0.5" + memory: 1Gi + limits: + cpu: "0.5" + memory: 2Gi + env: + - name: "TLS_CERT_FILE" + value: "/var/lib/secrets/sidecar-injector.crt" + - name: "TLS_KEY_FILE" + value: "/var/lib/secrets/sidecar-injector.key" + - name: "LOG_LEVEL" + value: "2" + - name: "CONFIG_DIR" + value: "conf/" + - name: "CONFIGMAP_LABELS" + value: "app=k8s-sidecar-injector" diff --git a/examples/patches-no-matches/base/kustomization.yaml b/examples/patches-no-matches/base/kustomization.yaml new file mode 100755 index 0000000000..e89291366b --- /dev/null +++ b/examples/patches-no-matches/base/kustomization.yaml @@ -0,0 +1,4 @@ +kind: Kustomization +apiVersion: kustomize.config.k8s.io/v1beta1 +resources: +- deployment.yaml diff --git a/examples/patches-no-matches/kustomization.yaml b/examples/patches-no-matches/kustomization.yaml new file mode 100644 index 0000000000..f1dd558eec --- /dev/null +++ b/examples/patches-no-matches/kustomization.yaml @@ -0,0 +1,6 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +bases: +- base +patches: +- patches.yaml diff --git a/examples/patches-no-matches/patches.yaml b/examples/patches-no-matches/patches.yaml new file mode 100644 index 0000000000..3e4da4e73f --- /dev/null +++ b/examples/patches-no-matches/patches.yaml @@ -0,0 +1,14 @@ +apiVersion: extensions/v1beta1 +kind: Deployment +metadata: + name: "k8s-sidecar-injector-prod" +spec: + template: + spec: + containers: + - name: "k8s-sidecar-injector" + env: + - name: "TLS_CERT_FILE" + value: "/var/lib/secrets/tls.crt" + - name: "TLS_KEY_FILE" + value: "/var/lib/secrets/tls.key"