Module: @kosko/template-deployed-service#

@kosko/template-deployed-service#

Create a new component including a deployment and a service.

Usage#

npx @kosko/template-deployed-service --name nginx --image nginx

Options#

--name#

Name of deployment and service. (Required)

--image#

Container image. (Required)

--type#

Service type. Default to ClusterIP.

--servicePort#

Service port. Default to 80.

--containerPort#

Container port. Default to 80.

--replicas#

Number of replicas. Default to 1.

Index#

Object literals#

Object literals#

template#

Const template: object

Defined in packages/template-deployed-service/src/template.ts:13

Properties:#

NameTypeValue
descriptionstring"Create a new component including a deployment and a service"
generatefunction(__namedParameters: { containerPort: number ; image: string ; name: string ; replicas: number ; servicePort: number ; type: string }) => Promise<{ files: { content: string = `"use strict"; const { Deployment } = require("kubernetes-models/apps/v1"); const { Service } = require("kubernetes-models/v1"); const metadata = { name: "${name}" }; const labels = { app: "${name}" }; const deployment = new Deployment({ metadata, spec: { replicas: ${replicas}, selector: { matchLabels: labels }, template: { metadata: { labels }, spec: { containers: [ { image: "${image}", name: "${name}", ports: [{ containerPort: ${containerPort} }] } ] } } } }); const service = new Service({ metadata, spec: { selector: labels, type: "${type}", ports: [ { port: ${servicePort}, targetPort: ${containerPort} } ] } }); module.exports = [deployment, service]; `; path: string = join("components", name + ".js") }[] = [ { path: join("components", name + ".js"), content: `"use strict"; const { Deployment } = require("kubernetes-models/apps/v1"); const { Service } = require("kubernetes-models/v1"); const metadata = { name: "${name}" }; const labels = { app: "${name}" }; const deployment = new Deployment({ metadata, spec: { replicas: ${replicas}, selector: { matchLabels: labels }, template: { metadata: { labels }, spec: { containers: [ { image: "${image}", name: "${name}", ports: [{ containerPort: ${containerPort} }] } ] } } } }); const service = new Service({ metadata, spec: { selector: labels, type: "${type}", ports: [ { port: ${servicePort}, targetPort: ${containerPort} } ] } }); module.exports = [deployment, service]; ` } ] }>
optionsobject{ containerPort: { default: number = 80; description: string = "Container port"; type: \"number\" = "number" } ; image: { description: string = "Container image"; required: true = true; type: \"string\" = "string" } ; name: { description: string = "Name of deployment and service"; required: true = true; type: \"string\" = "string" } ; replicas: { default: number = 1; description: string = "Number of replicas"; type: \"number\" = "number" } ; servicePort: { default: number = 80; description: string = "Service port"; type: \"number\" = "number" } ; type: { default: string = "ClusterIP"; description: string = "Service type"; type: \"string\" = "string" } }