operations-controller

module
v0.0.0-...-c749b2c Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 13, 2024 License: Apache-2.0

README

Operations Controller

Overview

Operations Controller is a Kubebuilder project. This Kubebuilder project features an Operation of type CustomResourceDefinition (CRD) and a Kubernetes Controller for it. It also provides several key resources that are accessible at the given locations:

  • api/v1alpha1/operation_types.go
    The operation_types.go file contains the CRD that is generated by the Operations Controller.

  • config/crd/bases/operations.compass_operations.yaml
    The operations.compass_operations.yaml file is generated from the operation_types.go CRD.

  • config/samples/operations_v1alpha1_operation.yaml
    The operations_v1alpha1_operation.yaml file contains a sample of the CRD.

  • controllers/operation_controller.go
    The operation_controller.go file is a Kubernetes controller for the CRD.

Prerequisites

  • Docker
  • Kubernetes CLI
  • Kubernetes cluster

Installation

CRD
Steps
  1. Generate the CRD.

make manifests

  1. Download the Kustomize binary locally.

make kustomize

  1. Build the CRD into a single file named crds.yaml.

./bin/kustomize build config/crd > crds.yaml

  1. Apply the generated CRD file onto a Kubernetes cluster.

kubectl apply -f crds.yaml

Controller
Prerequisites
  • Make sure you have the CRD installed.
Steps
  1. Deploy the Kubernetes controller for the operation CRD onto a Kubernetes cluster. To do that, create a Docker image.

docker build -t compass/${IMAGE_NAME}

  1. Push the Docker image to a Docker repository.

docker push ${IMAGE_NAME}

  1. Run the controller. To do that, create an instance of the Docker image in the Kubernetes cluster.

kubectl run operations-controller --image=${IMAGE_NAME}

Note: If there's an already existing Kubernetes deployment for the controller (that is, if you have a local installation of Compass), just hotswap its image.

Usage and Development

CRD
  1. Make the required changes to the CRD in ./api/v1alpha1/operation_types.go.

  2. Regenerate the CRD.

make manifests

  1. Copy the new generated CRD to the component's Helm chart at compass/chart/compass/charts/operations-controller. You can also use a Makefile target to do this.

make copy-crds-to-chart

Controller

If there are changes to the controller, you have to create a Docker image for the new version of the controller. Then, deploy the image manually on a Kubernetes cluster.

Directories

Path Synopsis
api
v1alpha1
Package v1alpha1 contains API Schema definitions for the operations v1alpha1 API group +kubebuilder:object:generate=true +groupName=operations.compass
Package v1alpha1 contains API Schema definitions for the operations v1alpha1 API group +kubebuilder:object:generate=true +groupName=operations.compass
controllersfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
internal
k8s
log

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL