Skip to main content

Kubernetes Deployment Management and Subscribed Services

This guide provides a comprehensive overview of the procedures involved in managing trial and subscribed deployments within a Kubernetes environment. It offers step-by-step instructions for various tasks, including the cleanup of expired trial deployments and the efficient management of node pools. By following the outlined process, users can ensure the seamless operation of their Kubernetes clusters, optimize resource allocation, and maintain the integrity of their deployments.

Overview

The system differentiates between trial and subscribed deployments, automatically handling the cleanup of expired trials and ensuring subscribed services are efficiently managed across node pools.

Prerequisites

  • Kubernetes cluster
  • kubectl configured to communicate with your cluster
  • Basic understanding of Kubernetes concepts (Deployments, Namespaces, Labels, Nodes)

Getting Started

Warning Users

Inform users about the trial policy via the application's UI:

Notice: Trial servers are reset after 6 hours of inactivity. Please redeploy if necessary. No data loss will occur.

Deployment Tags

Deployments are tagged according to their type and environment:

  • Trial Development: trial-dev
  • Trial Production: trial-prod
  • Subscribed Development: subscribed-dev
  • Subscribed Production: subscribed-prod

Organizing Deployments

Deployments are organized in namespaces corresponding to their type:

  • trial
  • subscribed

kubectl Commands

Listing Deployments

  • All Namespaces:

    kubectl get deployments --all-namespaces
  • Specific Namespace with Labels:

    kubectl get deployments -n <namespace> -l <label>=<value>

Deleting Expired Trials

  • Delete Deployment:
    kubectl delete deployment <deployment-name> -n <namespace>

Node Management

  • Label Nodes:

    kubectl label nodes <node-name> <label>=<value>
  • List Nodes by Label:

    kubectl get nodes -l <label>=<value>

Namespace Management

  • Create Namespace:
    kubectl create namespace <namespace-name>

CronJob for Cleanup

  • CronJob Definition Example:

    apiVersion: batch/v1
    kind: CronJob
    metadata:
    name: cleanup-expired-trials
    namespace: default
    spec:
    schedule: "0 * * * *"
    jobTemplate:
    spec:
    template:
    spec:
    containers:
    - name: cleanup
    image: cleanup-image
    command: ["./cleanup-script"]
    restartPolicy: OnFailure

    Apply the CronJob:

    kubectl apply -f cronjob-file.yaml

Monitoring and Logs

  • Deployment Logs:
    kubectl logs deployment/<deployment-name> -n <namespace>

Cluster and Resource Status

  • Cluster Info:

    kubectl cluster-info
  • Resource Status:

    kubectl get all -n <namespace>

Conclusion

This guide provides the foundation for managing trial and subscribed deployments within Kubernetes, leveraging kubectl for deployment and node management. Adjust and expand these instructions as necessary to fit your specific infrastructure and operational needs.