apiVersion: v1 kind: Pod metadata: namespace: <%= namespace %> name: <%= id %> labels: job: <%= id %> app.kubernetes.io/name: <%= container.name %> app.kubernetes.io/managed-by: open-ondemand <%- if !script.accounting_id.nil? && script.accounting_id != "" -%> account: <%= script.accounting_id %> <%- end -%> annotations: <%- unless script.wall_time.nil? -%> pod.kubernetes.io/lifetime: <%= helper.seconds_to_duration(script.wall_time) %> <%- end -%> spec: restartPolicy: <%= spec.container.restart_policy %> securityContext: runAsUser: <%= run_as_user %> runAsGroup: <%= run_as_group %> fsGroup: <%= fs_group %> containers: - name: "<%= spec.container.name %>" image: <%= spec.container.image %> imagePullPolicy: IfNotPresent <%- unless spec.container.working_dir.empty? -%> workingDir: "<%= spec.container.working_dir %>" <%- end -%> <%- unless spec.container.env.empty? -%> env: <%- spec.container.env.each do |env| -%> - name: <%= env[:name] %> value: "<%= env[:value] %>" <%- end # for each env -%> <%- end # unless env is nil -%> <%- unless spec.container.command.empty? -%> command: <%- spec.container.command.each do |cmd| -%> - "<%= cmd %>" <%- end # for each command -%> <%- end # unless command is nil -%> <%- unless spec.container.port.nil? -%> ports: - containerPort: <%= spec.container.port %> <%- end -%> volumeMounts: <%- unless configmap.nil? -%> - name: configmap-volume mountPath: <%= configmap_mount_path %> <%- end -%> <%- all_mounts.each do |mount| -%> - name: <%= mount[:name] %> mountPath: <%= mount[:destination_path] %> <%- end # for each mount -%> resources: limits: memory: "<%= spec.container.memory %>" cpu: "<%= spec.container.cpu %>" requests: memory: "<%= spec.container.memory %>" cpu: "<%= spec.container.cpu %>" <%- unless spec.init_containers.nil? -%> initContainers: <%- spec.init_containers.each do |ctr| -%> - name: "<%= ctr.name %>" image: "<%= ctr.image %>" command: <%- ctr.command.each do |cmd| -%> - "<%= cmd %>" <%- end # command loop -%> volumeMounts: <%- unless configmap.nil? -%> - name: configmap-volume mountPath: <%= configmap_mount_path %> <%- end -%> <%- all_mounts.each do |mount| -%> - name: <%= mount[:name] %> mountPath: <%= mount[:destination_path] %> <%- end # for each mount -%> <%- end # init container loop -%> <%- end # if init containers -%> <%- unless (configmap.to_s.empty? && all_mounts.empty?) -%> volumes: <%- unless configmap.to_s.empty? -%> - name: configmap-volume configMap: name: <%= configmap_name(id) %> <%- end -%> <%- all_mounts.each do |mount| -%> <%- if mount[:type] == 'nfs' -%> - name: <%= mount[:name] %> nfs: server: <%= mount[:host] %> path: <%= mount[:path] %> <%- elsif mount[:type] == 'host' -%> - name: <%= mount[:name] %> hostPath: path: <%= mount[:path] %> type: <%= mount[:host_type] %> <%- end # if mount is [host,nfs] -%> <%- end # for each mount -%> <%- end # (configmap.to_s.empty? || all_mounts.empty?) -%> --- <%- unless spec.container.port.nil? -%> apiVersion: v1 kind: Service metadata: name: <%= service_name(id) %> namespace: <%= namespace %> labels: job: <%= id %> spec: selector: job: <%= id %> ports: - protocol: TCP port: 80 targetPort: <%= spec.container.port %> type: NodePort <%- end # end for service -%> --- <%- unless configmap.nil? -%> apiVersion: v1 kind: ConfigMap metadata: name: <%= configmap_name(id) %> namespace: <%= namespace %> labels: job: <%= id %> data: <%= configmap.filename %>: | <% config_data_lines(configmap.data).each do |line| %><%= line %><% end %> <%- end # end for configmap -%>