template.yaml 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. apiVersion: template.openshift.io/v1
  2. kind: Template
  3. metadata:
  4. name: console-plugin-template
  5. annotations:
  6. openshift.io/display-name: OpenShift Console Plugin Template
  7. openshift.io/documentation-url: "https://github.com/spadgett/console-plugin-template"
  8. description: >-
  9. nginx HTTP server for an OpenShift console plugin creating using the
  10. template at https://github.com/spadgett/console-plugin-template
  11. iconClass: icon-nginx
  12. tags: openshift,console,plugin,nginx
  13. parameters:
  14. - description: Name of your plugin. This name must match the name in the consolePlugin declaration in package.json.
  15. name: PLUGIN_NAME
  16. value: console-plugin-template
  17. required: true
  18. - description: Namespace for your plugin. The namespace will be created by the template.
  19. name: NAMESPACE
  20. value: console-plugin-template
  21. required: true
  22. - description: Container image of the plugin.
  23. name: IMAGE
  24. value: quay.io/spadgett/console-plugin-template:latest
  25. required: true
  26. message: >-
  27. To enable the plugin on the cluster, run the following command:
  28. oc patch consoles.operator.openshift.io cluster --patch '{ "spec": { "plugins": ["${PLUGIN_NAME}"] } }' --type=merge
  29. For more information about using this template, see https://github.com/spadgett/console-plugin-template
  30. objects:
  31. - apiVersion: v1
  32. kind: Namespace
  33. metadata:
  34. name: '${NAMESPACE}'
  35. - apiVersion: apps/v1
  36. kind: Deployment
  37. metadata:
  38. name: '${PLUGIN_NAME}'
  39. namespace: '${NAMESPACE}'
  40. labels:
  41. app: '${PLUGIN_NAME}'
  42. app.kubernetes.io/component: '${PLUGIN_NAME}'
  43. app.kubernetes.io/instance: '${PLUGIN_NAME}'
  44. app.kubernetes.io/part-of: '${PLUGIN_NAME}'
  45. app.openshift.io/runtime-namespace: '${NAMESPACE}'
  46. spec:
  47. replicas: 1
  48. selector:
  49. matchLabels:
  50. app: '${PLUGIN_NAME}'
  51. template:
  52. metadata:
  53. labels:
  54. app: '${PLUGIN_NAME}'
  55. spec:
  56. containers:
  57. - name: '${PLUGIN_NAME}'
  58. image: '${IMAGE}'
  59. ports:
  60. - containerPort: 9443
  61. protocol: TCP
  62. imagePullPolicy: Always
  63. volumeMounts:
  64. - name: plugin-serving-cert
  65. readOnly: true
  66. mountPath: /var/serving-cert
  67. - name: nginx-conf
  68. readOnly: true
  69. mountPath: /etc/nginx/nginx.conf
  70. subPath: nginx.conf
  71. volumes:
  72. - name: plugin-serving-cert
  73. secret:
  74. secretName: plugin-serving-cert
  75. defaultMode: 420
  76. - name: nginx-conf
  77. configMap:
  78. name: nginx-conf
  79. defaultMode: 420
  80. restartPolicy: Always
  81. dnsPolicy: ClusterFirst
  82. strategy:
  83. type: RollingUpdate
  84. rollingUpdate:
  85. maxUnavailable: 25%
  86. maxSurge: 25%
  87. - apiVersion: v1
  88. kind: ConfigMap
  89. metadata:
  90. name: nginx-conf
  91. namespace: '${NAMESPACE}'
  92. labels:
  93. app: '${PLUGIN_NAME}'
  94. app.kubernetes.io/part-of: '${PLUGIN_NAME}'
  95. data:
  96. nginx.conf: |
  97. error_log /dev/stdout info;
  98. events {}
  99. http {
  100. access_log /dev/stdout;
  101. include /etc/nginx/mime.types;
  102. default_type application/octet-stream;
  103. keepalive_timeout 65;
  104. server {
  105. listen 9443 ssl;
  106. ssl_certificate /var/serving-cert/tls.crt;
  107. ssl_certificate_key /var/serving-cert/tls.key;
  108. root /usr/share/nginx/html;
  109. }
  110. }
  111. - apiVersion: v1
  112. kind: Service
  113. metadata:
  114. annotations:
  115. service.alpha.openshift.io/serving-cert-secret-name: plugin-serving-cert
  116. name: '${PLUGIN_NAME}'
  117. namespace: '${NAMESPACE}'
  118. labels:
  119. app: '${PLUGIN_NAME}'
  120. app.kubernetes.io/component: '${PLUGIN_NAME}'
  121. app.kubernetes.io/instance: '${PLUGIN_NAME}'
  122. app.kubernetes.io/part-of: '${PLUGIN_NAME}'
  123. spec:
  124. ports:
  125. - name: 9443-tcp
  126. protocol: TCP
  127. port: 9443
  128. targetPort: 9443
  129. selector:
  130. app: '${PLUGIN_NAME}'
  131. type: ClusterIP
  132. sessionAffinity: None
  133. - apiVersion: console.openshift.io/v1alpha1
  134. kind: ConsolePlugin
  135. metadata:
  136. name: '${PLUGIN_NAME}'
  137. spec:
  138. displayName: 'Console Plugin Template'
  139. service:
  140. name: '${PLUGIN_NAME}'
  141. namespace: '${NAMESPACE}'
  142. port: 9443
  143. basePath: '/'