template.yaml 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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: 2
  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. securityContext:
  64. allowPrivilegeEscalation: false
  65. capabilities:
  66. drop:
  67. - ALL
  68. resources:
  69. requests:
  70. cpu: 10m
  71. memory: 50Mi
  72. volumeMounts:
  73. - name: plugin-serving-cert
  74. readOnly: true
  75. mountPath: /var/serving-cert
  76. - name: nginx-conf
  77. readOnly: true
  78. mountPath: /etc/nginx/nginx.conf
  79. subPath: nginx.conf
  80. volumes:
  81. - name: plugin-serving-cert
  82. secret:
  83. secretName: plugin-serving-cert
  84. defaultMode: 420
  85. - name: nginx-conf
  86. configMap:
  87. name: nginx-conf
  88. defaultMode: 420
  89. restartPolicy: Always
  90. dnsPolicy: ClusterFirst
  91. securityContext:
  92. runAsNonRoot: true
  93. seccompProfile:
  94. type: RuntimeDefault
  95. strategy:
  96. type: RollingUpdate
  97. rollingUpdate:
  98. maxUnavailable: 25%
  99. maxSurge: 25%
  100. - apiVersion: v1
  101. kind: ConfigMap
  102. metadata:
  103. name: nginx-conf
  104. namespace: '${NAMESPACE}'
  105. labels:
  106. app: '${PLUGIN_NAME}'
  107. app.kubernetes.io/part-of: '${PLUGIN_NAME}'
  108. data:
  109. nginx.conf: |
  110. error_log /dev/stdout info;
  111. events {}
  112. http {
  113. access_log /dev/stdout;
  114. include /etc/nginx/mime.types;
  115. default_type application/octet-stream;
  116. keepalive_timeout 65;
  117. server {
  118. listen 9443 ssl;
  119. ssl_certificate /var/serving-cert/tls.crt;
  120. ssl_certificate_key /var/serving-cert/tls.key;
  121. root /usr/share/nginx/html;
  122. }
  123. }
  124. - apiVersion: v1
  125. kind: Service
  126. metadata:
  127. annotations:
  128. service.alpha.openshift.io/serving-cert-secret-name: plugin-serving-cert
  129. name: '${PLUGIN_NAME}'
  130. namespace: '${NAMESPACE}'
  131. labels:
  132. app: '${PLUGIN_NAME}'
  133. app.kubernetes.io/component: '${PLUGIN_NAME}'
  134. app.kubernetes.io/instance: '${PLUGIN_NAME}'
  135. app.kubernetes.io/part-of: '${PLUGIN_NAME}'
  136. spec:
  137. ports:
  138. - name: 9443-tcp
  139. protocol: TCP
  140. port: 9443
  141. targetPort: 9443
  142. selector:
  143. app: '${PLUGIN_NAME}'
  144. type: ClusterIP
  145. sessionAffinity: None
  146. - apiVersion: console.openshift.io/v1alpha1
  147. kind: ConsolePlugin
  148. metadata:
  149. name: '${PLUGIN_NAME}'
  150. spec:
  151. displayName: 'Console Plugin Template'
  152. service:
  153. name: '${PLUGIN_NAME}'
  154. namespace: '${NAMESPACE}'
  155. port: 9443
  156. basePath: '/'