*Environment*:

GCP Container Cluster

*Kube Version*:

kubectl version

Client Version: version.Info{Major:"1", Minor:"3", GitVersion:"v1.3.7", 
GitCommit:"a2cba278cba1f6881bb0a7704d9cac6fca6ed435", GitTreeState:"clean", 
BuildDate:"2016-09-12T23:15:30Z", GoVersion:"go1.6.2", Compiler:"gc", 
Platform:"linux/amd64"}

Server Version: version.Info{Major:"1", Minor:"4", GitVersion:"v1.4.8", 
GitCommit:"c5fcb1951afb8150e4574bc234aed957cb586eb0", GitTreeState:"clean", 
BuildDate:"2017-01-12T02:14:29Z", GoVersion:"go1.6.3", Compiler:"gc", 
Platform:"linux/amd64"}

 

In our Project we were trying to use the Configmaps/secrets heavily.

It's works when we consume the configmaps as a "Voulme Plugin". But it 
won't work when it consume as ENV.

root@localhost env-dir]# cat bcsp-env

discovery_app=discovery

discovery_port=8761

 

kubectl get configmaps bcsp-var -o yaml

apiVersion: v1

data:

  bcsp-env: |

    discovery_app=discovery

    discovery_port=8761

kind: ConfigMap

metadata:

  creationTimestamp: 2017-02-07T14:33:50Z

  name: bcsp-var

  namespace: default

  resourceVersion: "1689350"

  selfLink: /api/v1/namespaces/default/configmaps/bcsp-var

  uid: 7153f6a7-ed42-11e6-b230-42010af00056

 

I tried it in our app in deployment model, it won’t work. So i take an 
example in kubernetes site and test via busybox.

cat test.yml

apiVersion: v1

kind: Pod

metadata:

  name: test-pod

spec:

  containers:

    - name: test-container

      image: gcr.io/google_containers/busybox

      command: [ "/bin/sh", "-c", "echo $(DISCOVERY_APP) $(DISCOVERY_PORT)" 
]

      env:

        - name: DISCOVERY_APP

          valueFrom:

            configMapKeyRef:

              name: bcsp-var

              key: discovery_app

        - name: DISCOVERY_PORT

          valueFrom:

            configMapKeyRef:

              name: bcsp-var

              key: discovery_port

  restartPolicy: Never

The pod is failed with below messages

kubectl describe pod test-pod

Name:           test-pod

Namespace:      default

Node:           
gke-container-cluster-it-default-pool-e1732b12-jn5c/10.242.153.2

Start Time:     Tue, 07 Feb 2017 06:34:51 -0800

Labels:         <none>

Status:         Pending

IP:             10.8.1.21

Controllers:    <none>

Containers:

  test-container:

    Container ID:

    Image:              gcr.io/google_containers/busybox

    Image ID:

    Port:

    Command:

      /bin/sh

      -c

      echo $(DISCOVERY_APP) $(DISCOVERY_PORT)

    Requests:

      cpu:              100m

    State:              Waiting

      Reason:           RunContainerError

    Ready:              False

    Restart Count:      0

    Environment Variables:

      DISCOVERY_APP:    <set to the key 'discovery_app' of config map 
'bcsp-var'>

      DISCOVERY_PORT:   <set to the key 'discovery_port' of config map 
'bcsp-var'>

Conditions:

  Type          Status

  Initialized   True

  Ready         False

  PodScheduled  True

Volumes:

  default-token-1u3vc:

    Type:       Secret (a volume populated by a Secret)

    SecretName: default-token-1u3vc

QoS Tier:       Burstable

Events:

  FirstSeen     LastSeen        Count   
>From                                                            
SubobjectPath                   Type            Reason          Message

  ---------     --------        -----   
----                                                            
-------------                   --------        ------          -------

  26s           26s             1       {default-scheduler 
}                                                                            
Normal          Scheduled       Successfully assigned test-pod to 
gke-container-cluster-it-default-pool-e1732b12-jn5c

  26s           9s              3       {kubelet 
gke-container-cluster-it-default-pool-e1732b12-jn5c}   
spec.containers{test-container} Normal          Pulling         pulling 
image "gcr.io/google_containers/busybox"

  25s           8s              3       {kubelet 
gke-container-cluster-it-default-pool-e1732b12-jn5c}   
spec.containers{test-container} Normal          Pulled          
Successfully pulled image "gcr.io/google_containers/busybox"

  25s           8s              3       {kubelet 
gke-container-cluster-it-default-pool-e1732b12-jn5c}                            
       
Warning         FailedSync      Error syncing pod, skipping: failed to 
"StartContainer" for "test-container" with RunContainerError: 
"GenerateRunContainerOptions: Couldn't find key discovery_app in ConfigMap 
default/bcsp-var"

 

-- 
You received this message because you are subscribed to the Google Groups 
"Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to kubernetes-users+unsubscr...@googlegroups.com.
To post to this group, send email to kubernetes-users@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.

Reply via email to