adoagent-operator

command module
v0.0.0-...-74c8f85 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2021 License: MIT Imports: 11 Imported by: 0

README

adoagent-operator

Kubernetes operator for the Azure DevOps self-hosted pipe-line agents. The Operator adds an extra layer of configuration on top of the default images like proxy settings, destination ssh-keys, allowed IP CIDR blocks.

init.sh

#!/bin/bash

# docker and github repo username
export USERNAME='bartvanbenthem'
# image and bundle version
export VERSION=1.0.1
# operator repo and name
export OPERATOR_NAME='adoagent-operator'
export OPERATOR_GROUP='ado'
export OPERATOR_KIND='Agent'
export OPERATOR_DOMAIN='gofound.nl'

cd $OPERATOR_NAME
# scaffold operator
operator-sdk init --domain $OPERATOR_DOMAIN --repo github.com/$USERNAME/$OPERATOR_NAME --skip-go-version-check
operator-sdk create api --group $OPERATOR_GROUP --version v1alpha1 --kind $OPERATOR_KIND --resource --controller

# always run make after changing *_types.go and *_controller.go
make generate
make manifests

#######################################################
# Build the operator
make manifests
make docker-build docker-push IMG=docker.io/$USERNAME/$OPERATOR_NAME:v$VERSION

#######################################################
# test and deploy the operator
make deploy IMG=docker.io/$USERNAME/$OPERATOR_NAME:v$VERSION
kubectl create ns test
kubectl -n test apply -f config/samples/ado_v1alpha1_agent.yaml
kubectl -n test get agent agent-sample
kubectl -n test get pods
# cleanup deployment
make undeploy
kubectl delete ns test


#######################################################
#######################################################
# Operator Lifecycle Manager - create and install bundle
operator-sdk olm install
operator-sdk olm status

# set env vars for creating the bundle
export IMG=docker.io/$USERNAME/$OPERATOR_NAME:v$VERSION
export BUNDLE_IMG=docker.io/$USERNAME/$OPERATOR_NAME-bundle:v$VERSION

# make the olm bundle
make bundle
# build and push the bundle image:
make bundle-build bundle-push
# verify bundle
operator-sdk bundle validate docker.io/$USERNAME/$OPERATOR_NAME-bundle:v$VERSION

# installing the bundle
operator-sdk run bundle docker.io/$USERNAME/$OPERATOR_NAME-bundle:v$VERSION --timeout 15m

# apply custom resource example
kubectl create ns test
kubectl -n test apply -f config/samples/ado_v1alpha1_agent.yaml
kubectl -n test get agent agent-sample

#######################################################
#######################################################
# Cleaning up your cluster
k -n test get operators
operator-sdk cleanup adoagent-operator
# If your bundle is in a bad state, you can clean up all the OLM and OLM-dependent 
# resources by running the following command:
operator-sdk olm uninstall


#######################################################
# Redeploying from scratch
operator-sdk olm install

operator-sdk run bundle docker.io/$USERNAME/$OPERATOR_NAME-bundle:v1.0.0
kubectl apply -f config/sample/ado_v1alpha1_agent.yaml

Agent Sample

apiVersion: ado.gofound.nl/v1alpha1
kind: Agent
metadata:
  name: agent-sample
spec:
  size: 2
  configStringData: {}
  secretData: {}
  securityPolicy:
    podSelector:
      matchLabels:
        agent_cr: agent-sample
    policyTypes:
    - Egress
    egress:
    - to:
      - ipBlock:
          cidr: 10.0.0.0/24
      ports:
      - protocol: TCP
        port: 80

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
api
v1alpha1
Package v1alpha1 contains API Schema definitions for the ado v1alpha1 API group +kubebuilder:object:generate=true +groupName=ado.gofound.nl
Package v1alpha1 contains API Schema definitions for the ado v1alpha1 API group +kubebuilder:object:generate=true +groupName=ado.gofound.nl

Jump to

Keyboard shortcuts

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