libops

module
v0.0.0-...-5e1307b Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2023 License: Apache-2.0

README

libops

libops is an experimental golang module that aims to generate kubernetes resources in a consistent pattern.

Example

Package main

import (
	"fmt"

	appsv1 "k8s.io/api/apps/v1"
	corev1 "k8s.io/api/core/v1"

	"github.com/opdev/libops/resource"
)

func nginxDeployment() *appsv1.Deployment {
	return resource.Create().
		Deployment().
		In("demo-ns").
		Named("nginx").
		Labeled(
			map[string]string{
				"app": "nginx",
			},
		).
		WithContainers(
			// define nginx container
			resource.Create().
				Container().
				Named("nginx").
				Image("nginx:latest").
				Exposes(
					corev1.ContainerPort{
						Name:          "http",
						Protocol:      corev1.ProtocolTCP,
						ContainerPort: 80,
					},
					corev1.ContainerPort{
						Name:          "https",
						Protocol:      corev1.ProtocolTCP,
						ContainerPort: 443,
					},
				).
				Build(),
		).
		Build()
}

func main() {
	fmt.Printf("%+v\n", nginxDeployment())
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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