How to use the @kubernetes/client-node.V1Pod function in @kubernetes/client-node

To help you get started, we’ve selected a few @kubernetes/client-node examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github che-incubator / chectl / src / api / kube.ts View on Github external
async createPod(name: string,
                  image: string,
                  serviceAccount: string,
                  restartPolicy: string,
                  pullPolicy: string,
                  configMapEnvSource: string,
                  namespace: string) {
    const k8sCoreApi = this.kc.makeApiClient(CoreV1Api)
    let pod = new V1Pod()
    pod.metadata = new V1ObjectMeta()
    pod.metadata.name = name
    pod.metadata.labels = { app: name }
    pod.metadata.namespace = namespace
    pod.spec = new V1PodSpec()
    pod.spec.containers
    pod.spec.restartPolicy = restartPolicy
    pod.spec.serviceAccountName = serviceAccount
    let opContainer = new V1Container()
    opContainer.name = name
    opContainer.image = image
    opContainer.imagePullPolicy = pullPolicy
    let envFromSource = new V1EnvFromSource()
    envFromSource.configMapRef = new V1ConfigMapEnvSource()
    envFromSource.configMapRef.name = configMapEnvSource
    opContainer.envFrom = [envFromSource]
github brigadecore / brigade / brigade-worker / src / k8s.ts View on Github external
function newRunnerPod(
  podname: string,
  brigadeImage: string,
  imageForcePull: boolean,
  serviceAccount: string,
  resourceRequests: jobs.JobResourceRequest,
  resourceLimits: jobs.JobResourceLimit,
  jobAnnotations: { [key: string]: string },
  jobShell: string
): kubernetes.V1Pod {
  let pod = new kubernetes.V1Pod();
  pod.metadata = new kubernetes.V1ObjectMeta();
  pod.metadata.name = podname;
  pod.metadata.labels = {
    heritage: "brigade",
    component: "job"
  };
  pod.metadata.annotations = jobAnnotations;

  let c1 = new kubernetes.V1Container();
  c1.name = "brigaderun";
  c1.image = brigadeImage;

  if (jobShell == "") {
    jobShell = "/bin/sh";
  }
  c1.command = [jobShell, "/hook/main.sh"];