1.1.43 • Published 2 years ago

@madhouselabs/konfig v1.1.43

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

How to use

pnpx @madhouselabs/konfig generate
pnpx @madhouselabs/konfig make

konfig - JS Powered k8s application manifest templating

You can specify values configurations for deployment, services in various formats. The currently supported ones are js,json and yml.

following is a working example of configuration

const config = {
  appName: 'auth-api',
  namespace: 'hotspot',

  replica: 1,
  serviceAccount: 'hotspot-admin',
  containers: [
    {
      name: 'auth-api',
      image: {
        name: 'registry.madhouselabs.io/hotspot/api/auth:latest',
        pullPolicy: 'Always' // defaults to 'Always'
      },
      env: {
        NODE_ENV: 'production',
        CONFIG_FILE: '/hotspot/config.yml',
        SECRET_FILE: '/hotspot/secret.yml',
        GITLAB_INSTANCE_CALLBACK_URL:
          'https://git.madhouselabs.io/users/auth/jwt/callback',
        SLACK_WEBHOOK_URL:
          'https://hooks.slack.com/services/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',
      },
      resources: {
        cpu: {
          min: 150,
          max: 300,
        },
        memory: {
          min: 200,
          max: 400,
        },
      },

      liveness: {
        path: '/api/auth/healthy',
        port: 3000,
        initDelay: 15,  // defaults to 20
        period: 10,     // defaults to 10
      },

      volumes: {
        secret: [
          {
            mountPath: '/example',
            name: 'auth-api-secret',
            items: [
              {
                key: 'value',
                path: 'secret.yml',
              },
            ],
          },
        ],
        configMap: [
          {
            mountPath: '/example',
            name: 'auth-api-config',
            items: [
              {
                key: 'value',
                path: 'config.yml',
              },
            ],
          },
          {
            mountPath: '/sample-example',
            name: 'auth-api-config-2',
            items: [
              {
                key: 'value-2',
                path: 'config.yml2',
              },
            ],
          },
        ],
      },
    },
  ],
  expose: {
    tcp: {
      // externalPort: internalPort (pod port)
      // here 3000 is the externalPort, and 80 is the port exposed on the pod. ie. service would accept requests on port 3000, and then route it to port 80 of that pod internally
      3000: 80,
      4000: 8000,
    },
    udp: {
      4242: 12800,
    },
  },
  configMap: [
    {
      name: 'app-config',
      data: [
        {
          key: 'NODE_ENV',
          value: 'development',
        },
        {
          key: 'value',
          value: yaml.dump({
            NODE_ENV: 'development',
          }),
        },
      ],
    },
  ],
  secret: [
    {
      name: 'app-secret',
      data: [
        {
          key: 'value',
          value: yaml.dump({
            mongo: {
              uri: 'safkjsasakfjsaldjflksao',
              db: 'hotspot',
            },
          }),
        },
      ],
    },
  ],
};

export default config;

v1.1.1: added support to add env, secret and configmap from contents of a local file

1.1.43

2 years ago

1.1.42

2 years ago

1.1.41

2 years ago

1.1.40

2 years ago

1.1.39

2 years ago

1.1.38

2 years ago

1.1.37

2 years ago

1.1.36

2 years ago

1.1.35

2 years ago

1.1.34

2 years ago

1.1.33

2 years ago

1.1.32

2 years ago

1.1.31

2 years ago

1.1.30

2 years ago

1.1.29

2 years ago

1.1.28

2 years ago

1.1.27

2 years ago

1.1.26

2 years ago

1.1.25

2 years ago

1.1.24

2 years ago

1.1.23

2 years ago

1.1.22

2 years ago

1.1.21

2 years ago

1.1.20

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.1.17

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago