Skip to content

Tag function allowing interaction with the kubernetes node client through yaml configs.

License

Notifications You must be signed in to change notification settings

ThinkDeepTech/k8s-tag

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

99 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

k8s-tag

Tag function allowing interaction with the kubernetes node client through yaml configs.

DEPRECATION WARNING: This has been replaced by @thinkdeep/k8s and will no longer be receiving updates.

Dependencies

Usage

The goal of this project is to abstract out the complexity of the Kubernetes javascript client. Readability is improved by automating construction of K8s client objects that are hard to mentally map to the equivalent yaml configuration. Instead, the k8s tag is used with a yaml configuration which makes it easier to understand, familiar and examples of yaml configurations are ubiquitous online.

import {k8s} from '@thinkdeep/k8s-tag';

const options = {
    name: 'job-1',
    namespace: 'default',
    image: 'busybox',
    command: ['ls'],
    args: ['-l']
};

const job = k8s`
    apiVersion: "batch/v1"
    kind: "Job"
    metadata:
        name: "${options.name}"
        namespace: "${options.namespace || "default"}"
    spec:
        template:
            spec:
                containers:
                    - name: "${process.env.HELM_RELEASE_NAME}-data-collector"
                      image: "${options.image}"
                      command: ${options.command}
                      args: ${options.args}
                      envFrom:
                      - secretRef:
                          name: "${process.env.HELM_RELEASE_NAME}-deep-microservice-collection-secret"
                      ${ process.env.PREDECOS_KAFKA_SECRET ? `
                      - secretRef:
                          name: "${process.env.PREDECOS_KAFKA_SECRET}"
                      ` : ``}
                serviceAccountName: "${process.env.HELM_RELEASE_NAME}-secret-accessor-service-account"
                restartPolicy: "Never"
                imagePullSecrets:
                    - name: "docker-secret"
`;

// Create the job on the cluster.
await job.create();

// Delete the job on the cluster.
await job.delete();

About

Tag function allowing interaction with the kubernetes node client through yaml configs.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published