This is giving a brief introduction how to run License-Manager on a local or remote Kubernetes cluster.
- nvm: https://github.com/nvm-sh/nvm#installing-and-updating
- npm
- docker
- skaffold: https://skaffold.dev/docs/install/
- kubectl: https://kubernetes.io/docs/tasks/tools/#kubectl
- Locally running Kubernetes Cluster from any of the below options
- Helm: https://helm.sh/docs/intro/install/
- cdk8s
- On MAC:
brew install cdk8s
- On Linux:
npm install -g cdk8s-cli
- On MAC:
- Compile typescript code to javascript:
or
npm run compile
yarn watch
- Watch for changes and compile typescript in the background:
npm run watch
- Compile and synthesize:
npm run build
- Synthesize k8s manifests from charts to dist/ (ready for 'kubectl apply -f')
make k8s_synth
- Import/update k8s apis (you should check-in this directory):
npm run import
- Upgrade cdk8s modules to latest version:
npm run upgrade
- Upgrade cdk8s modules to latest "@next" version (last commit)
npm run upgrade:next
kubectl apply -f dist/<segment>-*yaml
- Switch to
k8s
folder:cd k8s
- Ensure using the right version of Node configured in
.nvmrc
:nvm use
- Install the required packages listed the
package.json
:npm install
- Run snapshot tests and synthesize the K8s manifests from charts to
dist/
folder:npm run build
- Apply the K8S manifests to the local Kubernetes cluster with the help of
skaffold
andkustomize
and wait until thelicensing-deployment-**\*** pod
is running:All required credentials for local development are part of the repo incd .. skaffold dev
k8s/loc00
folder. - In oder to access the environment locally you need to add the following line to the
/etc/hosts
file:echo "127.0.0.1 licensing.your-domain.loc" | sudo tee -a >> /etc/hosts
- License-Service status: https://licensing.opal.loc:8443/v1/status
To be able to connect to the licensing-db service you need to forward the port (configured to :5433):
make pg-port-forward
This is also helpful for running tests.
- The target cluster must exist.
- The target cluster should have been configured with required secrets and tools as described in README.md
- Required secrets:
- licensing-postgres-secret
- licensing-application-secret
- registry-credentials
- Required deployments:
- Postgres DB cluster
- Cloudflare tunnel
- Required secrets:
- You need a
kubeconfig
file to access the target cluster.
- Switch to
ks8
folder:cd k8s
- Ensure using the right version of Node configured in
.nvmrc
:nvm use
- Install the required packages listed in
package.json
:npm install
- Create K8s manifests from charts to
dist/
folder for the target segment:SEGMENT=<segment> IMAGE_TAG=<image_tag> npm run synth
- Connect ot the remote cluster:
export KUBECONFIG=</path/to/kubeconfig>
- Deploy the K8s manifests:
kubectl apply -f dist/<segment>-*yaml
- In order to see the pods created under the namespace
licensing
:kubectl -n licensing get pods
- In order to see the secrets created under the namespace
licensing
:kubectl -n licensing get secrets
- In order to see the cronjobs created under the namespace
licensing
:kubectl -n licensing get cronjobs
- In order to see the jobs created under the namespace
licensing
:kubectl -n licensing get jobs
- In order to see the configmaps created under the namespace
licensing
:kubectl -n licensing get configmap
- In order to see the deployments created under the namespace
licensing
:kubectl -n licensing get deployments
- In order to see the cronjobs created under the namespace
licensing
:kubectl -n licensing logs <podname>
- In order to describe the specific details of the resource created under the namespace
licensing
:kubectl -n licensing describe <resource_type> <resource_name>
- In order to create/configure the resource created:
kubectl -n licensing apply <folder_name>/<specific.yaml>
- In order to debug a container of a pod via pdb (this picks the first available container in the pod)
kubectl -n licensing get pods
kubectl -n licensing attach POD_NAME -it
## Structure
```mermaid
classDiagram
class PostgresChart {
+ConfigMap configMap
+Secret secret
+KubeService kubeService
+KubeDeployment kubeDeployment
}
class LicensingChart {
+KubeServiceAccount serviceAccount
+KubeRole role
+KubeRoleBinding
+LicensingService licensingService
+KubeIngress
}
class IngressNginxChart {
+Helm ingressNginx
}
class LicensingService {
+KubeDeployment
+KubeService
}
App --> PostgresChart
App --> LicensingChart
App --> IngressNginxChart
LicensingChart --> LicensingService