Openshift/Kubernetes volumes_from

11/1/2016

I'm trying to mimic volumes_from using Openshift/Kubernetes. I have container A packaging the app and container B server the packaged app.

I cannot use init containers since I'm stuck on kubernetes 1.2.

I've tried the postStart lifecycle hook, detailed here: How to mimic '--volumes-from' in Kubernetes

But, Openshift/Kubernetes is always complaining that container A is contantly crashing because once it's done packaging, it exits.

How do I get Openshift/Kubernetes to stop complaining about container A crashing and just accept that it finished it's job?

Or is there another way of having one container build a package for another container to run?

Thanks in advance for your time.

Update 1: I don't have kubectl, but using oc describe pod myapp-2-prehook:

me:~/Projects/myapp (master) $ oc describe pod myapp-2-prehook
Name:           myapp-2-prehook
Namespace:      myproject
Node:           my.host/my.ip
Start Time:     Tue, 01 Nov 2016 15:30:55 -1000
Labels:         openshift.io/deployer-pod-for.name=myapp-2
Status:         Failed
IP:
Controllers:    <none>
Containers:
  lifecycle:
    Container ID:       docker://97a5272ebfa56f0c40fdc95094f13da06dba889049f2cc964fe3e89f61bd7792
    Image:              my.ip:5000/myproject/myapp@sha256:cde5739c5f2bdc8c25b1dd514f698c543cfb6c8b68c3f1afbc7760e11597fde9
    Image ID:           docker://3be476fec505e5b979bac69d327d4ffb53b3f568e85547c5b66c229948435f44
    Port:
    Command:
      scripts/build.sh
    QoS Tier:
      cpu:              BestEffort
      memory:           BestEffort
    State:              Terminated
      Reason:           Error
      Exit Code:        1
      Started:          Tue, 01 Nov 2016 15:31:21 -1000
      Finished:         Tue, 01 Nov 2016 15:31:42 -1000
    Ready:              False
    Restart Count:      0
    Environment Variables:
      CUSTOM_VAR1:                      custom_value1
      OPENSHIFT_DEPLOYMENT_NAME:        myapp
      OPENSHIFT_DEPLOYMENT_NAMESPACE:   myproject
Conditions:
  Type          Status
  Ready         False 
Volumes:
  default-token-goe98:
    Type:       Secret (a volume populated by a Secret)
    SecretName: default-token-goe98
No events.

Output of oc get pod assessor-2-prehook -o yaml:

apiVersion: v1
kind: Pod
metadata:
  annotations:
    openshift.io/deployment.name: myapp-2
    openshift.io/scc: restricted
  creationTimestamp: 2016-11-02T01:30:55Z
  labels:
    openshift.io/deployer-pod-for.name: myapp-2
  name: myapp-2-prehook
  namespace: myproject
  resourceVersion: "21512896"
  selfLink: /api/v1/namespaces/myproject/pods/myapp-2-prehook
  uid: ffcb7766-a09b-11e6-9053-005056a65cf8
spec:
  activeDeadlineSeconds: 21600
  containers:
  - command:
    - scripts/build.sh
    env:
    - name: CUSTOM_VAR1
      value: custom_value1
    - name: OPENSHIFT_DEPLOYMENT_NAME
      value: myapp-2
    - name: OPENSHIFT_DEPLOYMENT_NAMESPACE
      value: myproject
    image: my.ip:5000/myproject/myapp@sha256:cde5739c5f2bdc8c25b1dd514f698c543cfb6c8b68c3f1afbc7760e11597fde9
    imagePullPolicy: IfNotPresent
    name: lifecycle
    resources: {}
    securityContext:
      privileged: false
      seLinuxOptions:
        level: s0:c21,c0
    terminationMessagePath: /dev/termination-log
    volumeMounts:
    - mountPath: /var/run/secrets/kubernetes.io/serviceaccount
      name: default-token-goe98
      readOnly: true
  dnsPolicy: ClusterFirst
  host: my.host
  imagePullSecrets:
  - name: default-dockercfg-srrog
  nodeName: my.host
  restartPolicy: Never
  securityContext:
    seLinuxOptions:
      level: s0:c21,c0
  serviceAccount: default
  serviceAccountName: default
  terminationGracePeriodSeconds: 30
  volumes:
  - name: default-token-goe98
    secret:
      secretName: default-token-goe98
status:
  conditions:
  - lastProbeTime: null
    lastTransitionTime: 2016-11-02T01:31:49Z
    message: 'containers with unready status: [lifecycle]'
    reason: ContainersNotReady
    status: "False"
    type: Ready
  containerStatuses:
  - containerID: docker://97a5272ebfa56f0c40fdc95094f13da06dba889049f2cc964fe3e89f61bd7792
    image: my.ip:5000/myproject/myapp@sha256:cde5739c5f2bdc8c25b1dd514f698c543cfb6c8b68c3f1afbc7760e11597fde9
    imageID: docker://3be476fec505e5b979bac69d327d4ffb53b3f568e85547c5b66c229948435f44
    lastState: {}
    name: lifecycle
    ready: false
    restartCount: 0
    state:
      terminated:
        containerID: docker://97a5272ebfa56f0c40fdc95094f13da06dba889049f2cc964fe3e89f61bd7792
        exitCode: 1
        finishedAt: 2016-11-02T01:31:42Z
        reason: Error
        startedAt: 2016-11-02T01:31:21Z
  hostIP: 128.49.90.62
  phase: Failed
  startTime: 2016-11-02T01:30:55Z
-- Zhao Li
kubernetes
openshift-origin

0 Answers