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

well-defined vars that were never replaced: EXTERNAL_IP #1734

Closed
dove-young opened this issue Nov 5, 2019 · 6 comments
Closed

well-defined vars that were never replaced: EXTERNAL_IP #1734

dove-young opened this issue Nov 5, 2019 · 6 comments
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.

Comments

@dove-young
Copy link

Hit error when refer to ConfigMap data in vars. And it seems like this error only happen to EXTERNAL_IP variable. EXTERNAL_PORT variable does not fails.

Here is my kustomization.yaml

cat base/kustomization.yaml
resources:
- nodejsapp-service.yml

configMapGenerator:
- name: nodejs-test-cm
  literals:
    - branch=develop
    - build=20191025
    - external_ip=10.0.0.3
    - external_port=3000

vars:
- name: EXTERNAL_IP
  objref:
    kind: ConfigMap
    name: nodejs-test-cm
    apiVersion: v1
  fieldref:
    fieldpath: data.external_ip
- name: EXTERNAL_PORT
  objref:
    kind: ConfigMap
    name: nodejs-test-cm
    apiVersion: v1
  fieldref:
    fieldpath: data.external_port
cat base/nodejsapp-service.yml
apiVersion: v1
kind: Service
metadata:
  name: "nodejs-test"
  labels:
    service: "nodejs-test"
spec:
  ports:
  - name: client-connect
    port: "$(EXTERNAL_PORT)"
    targetPort: 3000
  selector:
    app: "nodejs-test"
  type: ClusterIP
  externalIPs:
  - "$(EXTERNAL_IP)"
kustomize build base
2019/11/04 23:54:38 well-defined vars that were never replaced: EXTERNAL_IP
apiVersion: v1
data:
  branch: develop
  build: "20191025"
  external_ip: 10.0.0.3
  external_port: "3000"
kind: ConfigMap
metadata:
  name: nodejs-test-cm-g97k2f5dmt
---
apiVersion: v1
kind: Service
metadata:
  labels:
    service: nodejs-test
  name: nodejs-test
spec:
  externalIPs:
  - $(EXTERNAL_IP)
  ports:
  - name: client-connect
    port: "3000"
    targetPort: 3000
  selector:
    app: nodejs-test
  type: ClusterIP

here is kustomize version

 kustomize version
Version: {Version:kustomize/v3.3.0 GitCommit:7050c6a7b692fdba6e831e63c7b83920ab03ad76 BuildDate:2019-10-24T17:54:30Z GoOs:linux GoArch:amd64}
@jbrette
Copy link
Contributor

jbrette commented Nov 5, 2019

you are just missing the varreference. check here

@harshalkwagh
Copy link

harshalkwagh commented Dec 20, 2019

@jbrette Even after adding proper varReference variable replacement is inconstant

I am trying to replace few values in my deployment with variables. In some cases variable replacements is working properly but some of the cases its not replacing variables at all.
Example details are as below.

deployment.yaml:

---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: dkube-ui
    ksonnet.io/component: dkube-ui
  name: dkube-ui-$(verTag)
  namespace: dkube
spec:
  selector:
    matchLabels:
      app: dkube-ui
  template:
    metadata:
      labels:
        app: dkube-ui
    spec:
      containers:
      - command:
        - bash
        - -c
        - "echo \"Hello World\""
        image: dkubeUIImage
        imagePullPolicy: IfNotPresent
        name: main
        ports:
        - containerPort: 3000
          name: ui
          protocol: TCP
      dnsConfig:
        options:
        - name: single-request-reopen
        - name: timeout
          value: "30"
      imagePullSecrets:
      - name: $(dkubeDockerSecret)
      nodeSelector: NODE_SELECTOR

Params.env:

verTag=1-4-1
dkubeDockerSecret=dkube-dockerhub-secret

Params.yaml:

varReference:
- path: spec/template/spec
  kind: Deployment
- path: metadata
  kind: Deployment

kustomize.yaml:

resources:
- deployment.yaml
configMapGenerator:
- name: dkube-ui-config
  env: params.env
generatorOptions:
  disableNameSuffixHash: true
images:
- name: dkubeUIImage
  newName: docker.io/ocdr/dkube-uiserver
  newTag: 1.4.2
vars:
- name: verTag
  objref:
    kind: ConfigMap
    name: dkube-ui-config
    apiVersion: v1
  fieldref:
    fieldpath: data.verTag
- name: dkubeDockerSecret
  objref:
    kind: ConfigMap
    name: dkube-ui-config
    apiVersion: v1
  fieldref:
    fieldpath: data.dkubeDockerSecret
configurations:
- params.yaml

config-map.yaml:

apiVersion: v1
kind: ConfigMap
metadata:
  name: dkube-ui-config
  namespace: dkube
data:
  config: |
    {
    verTag: $(verTag),
    dkubeDockerSecret: $(dkubeDockerSecret)
    }

Here i am replacing 2 variables in my deployment, namely verTag and dkubeDockerSecret
verTag is getting replaced properly but dkubeDockerSecret is not getting replaced.

$ kustomize build

2019/12/20 16:00:23 well-defined vars that were never replaced: dkubeDockerSecret
apiVersion: v1
data:
  clusterDomain: cluster.local
  dkubeDockerSecret: dkube-dockerhub-secret
  verTag: 1-4-1
kind: ConfigMap
metadata:
  name: dkube-ui-config
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  labels:
    app: dkube-ui
    ksonnet.io/component: dkube-ui
  name: dkube-ui-1-4-1
  namespace: dkube
spec:
  selector:
    matchLabels:
      app: dkube-ui
  template:
    metadata:
      labels:
        app: dkube-ui
    spec:
      containers:
      - command:
        - bash
        - -c
        - echo "Hello World"
        image: docker.io/ocdr/dkube-uiserver:1.4.2
        imagePullPolicy: IfNotPresent
        name: main
        ports:
        - containerPort: 3000
          name: ui
          protocol: TCP
      dnsConfig:
        options:
        - name: single-request-reopen
        - name: timeout
          value: "30"
      imagePullSecrets:
      - name: $(dkubeDockerSecret)
      nodeSelector: NODE_SELECTOR

Can you please help me in understanding the problem and resolve it.

@fejta-bot
Copy link

Issues go stale after 90d of inactivity.
Mark the issue as fresh with /remove-lifecycle stale.
Stale issues rot after an additional 30d of inactivity and eventually close.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Mar 19, 2020
@fejta-bot
Copy link

Stale issues rot after 30d of inactivity.
Mark the issue as fresh with /remove-lifecycle rotten.
Rotten issues close after an additional 30d of inactivity.

If this issue is safe to close now please do so with /close.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/lifecycle rotten

@k8s-ci-robot k8s-ci-robot added lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed. and removed lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. labels Apr 18, 2020
@fejta-bot
Copy link

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

@k8s-ci-robot
Copy link
Contributor

@fejta-bot: Closing this issue.

In response to this:

Rotten issues close after 30d of inactivity.
Reopen the issue with /reopen.
Mark the issue as fresh with /remove-lifecycle rotten.

Send feedback to sig-testing, kubernetes/test-infra and/or fejta.
/close

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
lifecycle/rotten Denotes an issue or PR that has aged beyond stale and will be auto-closed.
Projects
None yet
Development

No branches or pull requests

5 participants