eirinictrl

package module
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2022 License: Apache-2.0 Imports: 1 Imported by: 0

README

Eirini

 

What is Eirini Controller?

Eirini Controller is a Kubernetes controller that aims to enable Cloud Foundry to deploy applications as Pods on a Kubernetes cluster. It brings the CF model to Kubernetes by definig well known Diego abstractions such as Long Running Processes (LRPs) and Tasks as custom Kubernetes resources.

Installation

Prerequisites

  • A Kubernetes cluster (kind works fine)
  • kubectl
  • helm
  • The eirini-controller system and workloads namespaces need to be created upfront
kubectl create ns eirini-controller
kubectl create ns cf-workloads
  • Secrets containing certificates for the webhooks need to be created. We have a script that does that for local dev and testing purposes
curl https://raw.githubusercontent.com/cloudfoundry/eirini-controller/master/deployment/scripts/generate-secrets.sh | bash -s - "*.eirini-controller.svc"

Installing an eirini-controllers release

In ordrer to install eirini-controller to your k8s cluster, run the command below, replacing x.y.z with a valid release version

VERSION=x.y.z; \
WEBHOOK_CA_BUNDLE="$(kubectl get secret -n eirini-controller eirini-webhooks-certs -o jsonpath="{.data['tls\.ca']}")"; \
helm install eirini-controller https://github.com/cloudfoundry/eirini-controller/releases/download/v$VERSION/eirini-controller-$VERSION.tgz \
  --namespace eirini-controller \
  --set "webhooks.ca_bundle=$WEBHOOK_CA_BUNDLE"

Usage

Running an LRP

cat <<EOF | kubectl apply -f -
apiVersion: eirini.cloudfoundry.org/v1
kind: LRP
metadata:
  name: mylrp
  namespace: cf-workloads
spec:
  GUID: $(uuidgen)
  diskMB: 256
  image: eirini/dorini
EOF

You can see the resources created by eirini by running

kubectl get all -n cf-workloads

A statefulset and a pod should appear. Eirini does not provide a network layer, so if you want to access your LRP you have to do it from within the cluster or use telepresence.

POD_IP=$(kubectl get pod -n cf-workloads --selector=korifi.cloudfoundry.org/source-type=APP -o jsonpath="{.items[0].status.podIP}")
telepresence --run curl http://$POD_IP:8080/ 2>/dev/null

Running a Task

cat <<EOF | kubectl apply -f -
apiVersion: eirini.cloudfoundry.org/v1
kind: Task
metadata:
  name: mytask
  namespace: cf-workloads
spec:
  GUID: $(uuidgen)
  image: eirini/busybox
  command: ["/bin/echo", "Hello!"]
EOF

In order to see the greeting message, run the following command

kubectl logs -n cf-workloads --selector=korifi.cloudfoundry.org/source-type=TASK

Documentation

Index

Constants

View Source
const (
	// Environment Variable Names
	EnvEiriniCertsDir = "EIRINI_CERTS_DIR"

	EnvPodName              = "POD_NAME"
	EnvCFInstanceIP         = "CF_INSTANCE_IP"
	EnvCFInstanceIndex      = "CF_INSTANCE_INDEX"
	EnvCFInstanceGUID       = "CF_INSTANCE_GUID"
	EnvCFInstanceInternalIP = "CF_INSTANCE_INTERNAL_IP"
	EnvCFInstanceAddr       = "CF_INSTANCE_ADDR"
	EnvCFInstancePort       = "CF_INSTANCE_PORT"
	EnvCFInstancePorts      = "CF_INSTANCE_PORTS"

	EiriniCertsDir = "/etc/eirini/certs"
)

Variables

View Source
var ErrInvalidInstanceIndex = errors.New("invalid instance index")
View Source
var ErrNotFound = errors.New("not found")

Functions

This section is empty.

Types

type ControllerConfig

type ControllerConfig struct {
	KubeConfig `yaml:",inline"`

	ApplicationServiceAccount               string `yaml:"application_service_account"`
	RegistrySecretName                      string `yaml:"registry_secret_name"`
	UnsafeAllowAutomountServiceAccountToken bool   `yaml:"unsafe_allow_automount_service_account_token"`
	DefaultMinAvailableInstances            string `yaml:"default_min_available_instances"`

	WorkloadsNamespace string

	PrometheusPort int `yaml:"prometheus_port"`
	TaskTTLSeconds int `yaml:"task_ttl_seconds"`

	LeaderElectionID        string
	LeaderElectionNamespace string

	WebhookPort int32 `yaml:"webhook_port"`
}

type KubeConfig

type KubeConfig struct {
	ConfigPath string `yaml:"kube_config_path"`
}

Directories

Path Synopsis
cmd
k8s
jobs/jobsfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
k8sfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
pdb
reconciler/reconcilerfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
stset/stsetfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
webhook
Package webhook container extensions to use with eirinix
Package webhook container extensions to use with eirinix
pkg
apis/eirini/v1
+kubebuilder:validation:Optional
+kubebuilder:validation:Optional
generated/clientset/versioned
This package has the automatically generated clientset.
This package has the automatically generated clientset.
generated/clientset/versioned/fake
This package has the automatically generated fake clientset.
This package has the automatically generated fake clientset.
generated/clientset/versioned/scheme
This package contains the scheme of the automatically generated clientset.
This package contains the scheme of the automatically generated clientset.
generated/clientset/versioned/typed/eirini/v1
This package has the automatically generated typed clients.
This package has the automatically generated typed clients.
generated/clientset/versioned/typed/eirini/v1/fake
Package fake has the automatically generated clients.
Package fake has the automatically generated clients.
prometheusfakes
Code generated by counterfeiter.
Code generated by counterfeiter.
utilfakes
Code generated by counterfeiter.
Code generated by counterfeiter.

Jump to

Keyboard shortcuts

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