Skip to main content

Kubernetes and Docker Config

This package is a generator that sets up configuration template files in application root folder that Jenkins needs in order to deploy services (micro-applications) to host servers through kubernetes and ingress. The config generator serves as a streamlined interface for developers to configure service build and deployment.

info

K8s is the abbreviation for Kubernetes. K8 templates and docker files are both used to build docker images for a service and deploy these as running container on a cloud server ** For more information on deployments in Kubernetes, please refer to https://kubernetes.io/docs/concepts/workloads/controllers/deployment/

Usage​

To create Kubernetes and Docker Config, you can follow the steps outlined below:

Pre-requisites​

  • Make sure you are on correct version of Nodejs 18.x and Nx Version 16.6

    node --version
    nx --version
  • To start with, create a new GenesisX workspace in an empty directory, run below command, of if you already have the workspace ready , please skip this step.

    npx @genesisx/create-workspace
    • Provide the requested parameters

    • Provide name to your workspace like test-workspace

    • Move to the created workspace - cd test-workspace

    • Install the packages

      yarn install
  • Install Kubernetes and Docker Config package

    yarn add @genesisx/k8-docker-config
  • Now follow either of the two modes(mentioned below) to use this generator - either the Nx Console or CLI

info

Two types of configuration templates can be generated using the GenesisX generator, which is known as "@genesis-k8Configs":

  • K8 configs
  • Dockerfile

Via Nx Console​

  1. We highly recommend installing Nx Console extension in IDE for fast and easy user interface. Please refer to https://nx.dev/l/r/getting-started/console for steps for installation. Select Generator tool from the NX console as shown in the image in your IDE

  2. Navigate to Nx Console > Generate > @genesisx/k8-docker-config

K8s generator
  1. Fill in the form to decide on what type of config files you want to create(k8/dockerfile/both). Following fields to enter:
  • project: Select the Project App Name to update its folders with deployment configs.
  • appName : Application name to be added to content of deployment config files: service.yml, ingress.yml, deployment.yml and Dockerfile.
  • namespace: Namespace to be added to the service deployment.
  • hostname: Host name of where the service will be deployed.
  • path: Route at which the service will be reachable.
  • imageName: Path to the docker image to be deployed onto kubernetes for a particular service.
NX Form Selections
  1. When run button is activated, the config files will be copied as in the below folder structure example
NX Form Selections

Via Command Line​

In case the Nx Console does not work, use below command to use this generator

 nx generate @genesisx/k8-docker-config:templated --project <projectName> --appName <appName> --imageName <imageName> --configFiles <configOption>
info
  • projectName is the name of the app where you want the k8 and/or docker setup
  • appName is to be added to content of K8s files like service.yml, ingress.yml, deployment.yml and Docker files under the chosen project
  • imageName is to be added K8 deployment.yaml only
  • configFiles can be either k8, docker or both (all)

More details & Troubleshooting​

Visit the troubleshooting guide for common issues or refer to the readme.md file located within the package folder <workspace-folder>/node_modules/@genesisx/k8-docker-config/README.md