2017-06-22 107 views
1

創建模板,我試圖生成我的現有設置的模板與OpenShift從現有的設置

oc export dc,svc,bc --selector="microservice=imagesvc" -o yaml --as-template=imagesvc 

的問題是,模板點容器源到我的reigstry。我想修改模板的方式是構建配置從源代碼構建容器,然後將其附加到deploymentconfig。我怎樣才能達到這樣的目標?

這是我目前擁有的配置。當我申請我會得到各種錯誤。作爲構建中的一個例子,我得到「無效的輸出參考」

任何幫助,這將不勝感激。

apiVersion: v1 
kind: Template 
metadata: 
    creationTimestamp: null 
    name: imagesvc 
objects: 
- apiVersion: v1 
    kind: DeploymentConfig 
    metadata: 
    annotations: 
     openshift.io/generated-by: OpenShiftWebConsole 
    creationTimestamp: null 
    generation: 1 
    labels: 
     app: gcsimageupload 
     microservice: imagesvc 
    name: gcsimageupload 
    spec: 
    replicas: 1 
    selector: 
     deploymentconfig: gcsimageupload 
    strategy: 
     activeDeadlineSeconds: 21600 
     resources: {} 
     rollingParams: 
     intervalSeconds: 1 
     maxSurge: 25% 
     maxUnavailable: 25% 
     timeoutSeconds: 600 
     updatePeriodSeconds: 1 
     type: Rolling 
    template: 
     metadata: 
     creationTimestamp: null 
     labels: 
      app: gcsimageupload 
      deploymentconfig: gcsimageupload 
      microservice: imagesvc 
     spec: 
     containers: 
     - imagePullPolicy: Always 
      livenessProbe: 
      failureThreshold: 3 
      httpGet: 
       path: /healthz 
       port: 8080 
       scheme: HTTP 
      initialDelaySeconds: 30 
      periodSeconds: 10 
      successThreshold: 1 
      timeoutSeconds: 10 
      name: gcsimageupload 
      ports: 
      - containerPort: 8080 
      protocol: TCP 
      readinessProbe: 
      failureThreshold: 3 
      httpGet: 
       path: /healthz 
       port: 8080 
       scheme: HTTP 
      initialDelaySeconds: 10 
      periodSeconds: 10 
      successThreshold: 1 
      timeoutSeconds: 1 
      resources: {} 
      terminationMessagePath: /dev/termination-log 
      volumeMounts: 
      - mountPath: /secret 
      name: gcsimageupload-secret 
      readOnly: true 
     dnsPolicy: ClusterFirst 
     restartPolicy: Always 
     securityContext: {} 
     terminationGracePeriodSeconds: 30 
     volumes: 
     - name: gcsimageupload-secret 
      secret: 
      defaultMode: 420 
      secretName: gcsimageupload-secret 
    test: false 
    triggers: 
    - imageChangeParams: 
     automatic: true 
     containerNames: 
     - gcsimageupload 
     from: 
      kind: ImageStreamTag 
      name: gcsimageupload:latest 
      namespace: web 
     type: ImageChange 
    - type: ConfigChange 
    status: 
    availableReplicas: 0 
    latestVersion: 0 
    observedGeneration: 0 
    replicas: 0 
    unavailableReplicas: 0 
    updatedReplicas: 0 
- apiVersion: v1 
    kind: DeploymentConfig 
    metadata: 
    annotations: 
     openshift.io/generated-by: OpenShiftWebConsole 
    creationTimestamp: null 
    generation: 1 
    labels: 
     app: imagesvc 
     microservice: imagesvc 
    name: imagesvc 
    spec: 
    replicas: 1 
    selector: 
     deploymentconfig: imagesvc 
    strategy: 
     activeDeadlineSeconds: 21600 
     resources: {} 
     rollingParams: 
     intervalSeconds: 1 
     maxSurge: 25% 
     maxUnavailable: 25% 
     timeoutSeconds: 600 
     updatePeriodSeconds: 1 
     type: Rolling 
    template: 
     metadata: 
     creationTimestamp: null 
     labels: 
      app: imagesvc 
      deploymentconfig: imagesvc 
      microservice: imagesvc 
     spec: 
     containers: 
     - imagePullPolicy: Always 
      livenessProbe: 
      failureThreshold: 3 
      httpGet: 
       path: /healthz 
       port: 8080 
       scheme: HTTP 
      initialDelaySeconds: 30 
      periodSeconds: 10 
      successThreshold: 1 
      timeoutSeconds: 10 
      name: imagesvc 
      ports: 
      - containerPort: 8080 
      protocol: TCP 
      readinessProbe: 
      failureThreshold: 3 
      httpGet: 
       path: /healthz 
       port: 8080 
       scheme: HTTP 
      initialDelaySeconds: 30 
      periodSeconds: 10 
      successThreshold: 1 
      timeoutSeconds: 10 
      resources: {} 
      terminationMessagePath: /dev/termination-log 
     dnsPolicy: ClusterFirst 
     restartPolicy: Always 
     securityContext: {} 
     terminationGracePeriodSeconds: 30 
    test: false 
    triggers: 
    - imageChangeParams: 
     automatic: true 
     containerNames: 
     - imagesvc 
     from: 
      kind: ImageStreamTag 
      name: imagesvc:latest 
      namespace: web 
     type: ImageChange 
    - type: ConfigChange 
    status: 
    availableReplicas: 0 
    latestVersion: 0 
    observedGeneration: 0 
    replicas: 0 
    unavailableReplicas: 0 
    updatedReplicas: 0 
- apiVersion: v1 
    kind: DeploymentConfig 
    metadata: 
    annotations: 
     openshift.io/generated-by: OpenShiftWebConsole 
    creationTimestamp: null 
    generation: 1 
    labels: 
     app: imaginary 
     microservice: imagesvc 
    name: imaginary 
    spec: 
    replicas: 1 
    selector: 
     app: imaginary 
     deploymentconfig: imaginary 
    strategy: 
     activeDeadlineSeconds: 21600 
     resources: {} 
     rollingParams: 
     intervalSeconds: 1 
     maxSurge: 25% 
     maxUnavailable: 25% 
     timeoutSeconds: 600 
     updatePeriodSeconds: 1 
     type: Rolling 
    template: 
     metadata: 
     annotations: 
      openshift.io/generated-by: OpenShiftWebConsole 
     creationTimestamp: null 
     labels: 
      app: imaginary 
      deploymentconfig: imaginary 
      microservice: imagesvc 
     spec: 
     containers: 
     - image: h2non/imaginary 
      imagePullPolicy: Always 
      livenessProbe: 
      failureThreshold: 3 
      httpGet: 
       path: /health 
       port: 9000 
       scheme: HTTP 
      initialDelaySeconds: 10 
      periodSeconds: 10 
      successThreshold: 1 
      timeoutSeconds: 1 
      name: imaginary 
      ports: 
      - containerPort: 9000 
      protocol: TCP 
      readinessProbe: 
      failureThreshold: 3 
      httpGet: 
       path: /health 
       port: 9000 
       scheme: HTTP 
      initialDelaySeconds: 60 
      periodSeconds: 10 
      successThreshold: 1 
      timeoutSeconds: 1 
      resources: {} 
      terminationMessagePath: /dev/termination-log 
     dnsPolicy: ClusterFirst 
     restartPolicy: Always 
     securityContext: {} 
     terminationGracePeriodSeconds: 30 
    test: false 
    triggers: 
    - type: ConfigChange 
    - imageChangeParams: 
     automatic: true 
     containerNames: 
     - imaginary 
     from: 
      kind: ImageStreamTag 
      name: imaginary:latest 
      namespace: web 
     type: ImageChange 
    status: 
    availableReplicas: 0 
    latestVersion: 0 
    observedGeneration: 0 
    replicas: 0 
    unavailableReplicas: 0 
    updatedReplicas: 0 
- apiVersion: v1 
    kind: Service 
    metadata: 
    annotations: 
     openshift.io/generated-by: OpenShiftWebConsole 
    creationTimestamp: null 
    labels: 
     app: gcsimageupload 
     microservice: imagesvc 
    name: gcsimageupload 
    spec: 
    ports: 
    - name: 8080-tcp 
     port: 8080 
     protocol: TCP 
     targetPort: 8080 
    selector: 
     deploymentconfig: gcsimageupload 
    sessionAffinity: None 
    type: ClusterIP 
    status: 
    loadBalancer: {} 
- apiVersion: v1 
    kind: Service 
    metadata: 
    annotations: 
     openshift.io/generated-by: OpenShiftWebConsole 
     service.alpha.openshift.io/dependencies: '[{"name":"gcsimageupload","namespace":"","kind":"Service"},{"name":"imaginary","namespace":"","kind":"Service"}]' 
    creationTimestamp: null 
    labels: 
     app: imagesvc 
     microservice: imagesvc 
    name: imagesvc 
    spec: 
    ports: 
    - name: 8080-tcp 
     port: 8080 
     protocol: TCP 
     targetPort: 8080 
    selector: 
     deploymentconfig: imagesvc 
    sessionAffinity: None 
    type: ClusterIP 
    status: 
    loadBalancer: {} 
- apiVersion: v1 
    kind: Service 
    metadata: 
    annotations: 
     openshift.io/generated-by: OpenShiftWebConsole 
    creationTimestamp: null 
    labels: 
     app: imaginary 
     microservice: imagesvc 
    name: imaginary 
    spec: 
    ports: 
    - name: 9000-tcp 
     port: 9000 
     protocol: TCP 
     targetPort: 9000 
    selector: 
     deploymentconfig: imaginary 
    sessionAffinity: None 
    type: ClusterIP 
    status: 
    loadBalancer: {} 
- apiVersion: v1 
    kind: BuildConfig 
    metadata: 
    annotations: 
     openshift.io/generated-by: OpenShiftWebConsole 
    creationTimestamp: null 
    labels: 
     app: gcsimageupload 
     microservice: imagesvc 
    name: gcsimageupload 
    spec: 
    nodeSelector: null 
    output: 
     to: 
     kind: ImageStreamTag 
     name: gcsimageupload:latest 
    postCommit: {} 
    resources: {} 
    runPolicy: Serial 
    source: 
     git: 
     ref: master 
     uri: https://github.com/un1x86/openshift-ms-gcsFileUpload.git 
     type: Git 
    strategy: 
     sourceStrategy: 
     env: 
     - name: GCS_PROJECT 
      value: ${GCS_PROJECT_ID} 
     - name: GCS_KEY_FILENAME 
      value: ${GCS_KEY_FILENAME} 
     - name: GCS_BUCKET 
      value: ${GCS_BUCKET} 
     from: 
      kind: ImageStreamTag 
      name: nodejs:4 
      namespace: openshift 
     type: Source 
    triggers: 
    - github: 
     secret: f9928132855c5a30 
     type: GitHub 
    - generic: 
     secret: 77ece14f810caa3f 
     type: Generic 
    - imageChange: {} 
     type: ImageChange 
    - type: ConfigChange 
    status: 
    lastVersion: 0 
- apiVersion: v1 
    kind: BuildConfig 
    metadata: 
    annotations: 
     openshift.io/generated-by: OpenShiftWebConsole 
    creationTimestamp: null 
    labels: 
     app: imagesvc 
     microservice: imagesvc 
    name: imagesvc 
    spec: 
    nodeSelector: null 
    output: 
     to: 
     kind: ImageStreamTag 
     name: imagesvc:latest 
    postCommit: {} 
    resources: {} 
    runPolicy: Serial 
    source: 
     git: 
     ref: master 
     uri: https://github.com/un1x86/openshift-ms-imagesvc.git 
     type: Git 
    strategy: 
     sourceStrategy: 
     env: 
     - name: IMAGINARY_APPLICATION_DOMAIN 
      value: http://imaginary:9000 
     - name: GCSIMAGEUPLOAD_APPLICATION_DOMAIN 
      value: http://gcsimageupload:8080 
     from: 
      kind: ImageStreamTag 
      name: nodejs:4 
      namespace: openshift 
     type: Source 
    triggers: 
    - generic: 
     secret: 945da12357ef35cf 
     type: Generic 
    - github: 
     secret: 18106312cfa8e2d1 
     type: GitHub 
    - imageChange: {} 
     type: ImageChange 
    - type: ConfigChange 
    status: 
    lastVersion: 0 
parameters: 
    - description: "GCS Project ID" 
     name: GCS_PROJECT_ID 
     value: "" 
     required: true 
    - description: "GCS Key Filename" 
     name: GCS_KEY_FILENAME 
     value: /secret/keyfile.json 
     required: true 
    - description: "GCS Bucket name" 
     name: GCS_BUCKET 
     value: "" 
     required: true 

回答

0

您將需要創建兩個名爲「imagesvc」和「gcsimageupload」的圖像流。您可以通過cli「oc create is」或者通過添加到模板來完成:

- kind: ImageStream 
    apiVersion: v1 
    metadata: 
    name: <name> 
    spec: 
    lookupPolicy: 
     local: false 
+0

更簡單的方法是導出'is'以及'dc,svc,bc'以開始。儘管如此,仍然需要進行一些修復,因爲導出機制仍將引用保留在映像註冊表中,而不是正確引用映像流。如果OP可以通過包含'is'的輸出更新問題,則可以指出需要的其他更改。 –