api-operator

module
v0.0.0-...-036f9fd Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2022 License: Apache-2.0

README

Developer Guide

Build from source

Prerequisites
Build the source and the Docker image
>> mvn clean install
  • The docker image of the operator gets created.
Push the docker image (Optional)
  • Create a settings.xml file in ~/.m2 directory of Maven.
  • Include the following in the settings.xml and replace USERNAME AND PASSWORD fields
<settings xmlns="http://maven.apache.org/SETTINGS/1.1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.1.0 http://maven.apache.org/xsd/settings-1.1.0.xsd">
  <servers>
  	<server>
   		<id>docker.io</id>
   		<username>USERNAME</username>
   		<password>PASSWORD</password>
  	</server>
  </servers>
</settings>
  • Execute the following command to push the docker image to the repository
>> mvn dockerfile:push

Advanced Configurations

  1. After modifying the *_types.go files run the following command to update the generated code for that resource type

    >> operator-sdk generate k8s
    >> operator-sdk generate crds
    
  2. Build the api-operator image (Optional: Use mvn clean install)

    >> operator-sdk build wso2/k8s-api-operator:2.0.3
    
  3. Replace the image name in deploy/controller-artifacts/operator.yaml#L36

  4. Push it to a registry:

    >> docker push wso2/k8s-api-operator:2.0.3
    

Add new API and controller

  1. Adding new custom resource definition

    >> operator-sdk add api --api-version=wso2.com/v1alpha1 --kind=<kind name>
    
  2. Add a new Controller to the project

    >> operator-sdk add controller --api-version=wso2.com/v1alpha1 --kind=<kind name>
    

Running Unit Tests

  • Execute the following command to run unit tests

    >> gotest -v -covermode=count -coverprofile=coverage.out ./pkg/...
    
  • Check coverage locally

    >> go tool cover -html=coverage.out
    

How to Debug API Operator

Copy following certs in the directory build/security to /home/wso2/security/ (or update the cert directory in this file to the path build/security)

Install API Operator from distribution and delete the API Operator deployment.

kubectl delete deploy api-operator

Execute cmd/manager/main.go file in debug mode.

Directories

Path Synopsis
cmd
pkg
apis/serving/v1alpha1
Package v1alpha1 contains API Schema definitions for the serving v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=serving.knative.dev Package v1alpha1 contains API Schema definitions for the serving v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=serving.knative.dev
Package v1alpha1 contains API Schema definitions for the serving v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=serving.knative.dev Package v1alpha1 contains API Schema definitions for the serving v1alpha1 API group +k8s:deepcopy-gen=package,register +groupName=serving.knative.dev
apis/wso2/v1alpha2
Package v1alpha2 contains API Schema definitions for the wso2 v1alpha2 API group +k8s:deepcopy-gen=package,register +groupName=wso2.com Package v1alpha2 contains API Schema definitions for the wso2 v1alpha2 API group +k8s:deepcopy-gen=package,register +groupName=wso2.com
Package v1alpha2 contains API Schema definitions for the wso2 v1alpha2 API group +k8s:deepcopy-gen=package,register +groupName=wso2.com Package v1alpha2 contains API Schema definitions for the wso2 v1alpha2 API group +k8s:deepcopy-gen=package,register +groupName=wso2.com
envoy/server/api/restserver
Package restserver Internal Utility API This document specifies a **RESTful API** for allowing you to access internal data .
Package restserver Internal Utility API This document specifies a **RESTful API** for allowing you to access internal data .
k8s
str

Jump to

Keyboard shortcuts

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