ezops

package module
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 19 Imported by: 0

README

ezops

Go Reference

A simple GitOps tool, based on one-off run, easy to integrate with existing CI/CD routine

NO DAEMON, NO SERVICE, JUST ONE-OFF EXECUTION

中文使用说明

ezops - 简易 GitOps 工具

Features

  • Support yaml, json, jsonnet and Helm
  • Incremental update

Installation

You can either build binary from source, or just download pre-built binary.

Usage

  1. Ensure kubectl and helm are available in $PATH
  2. Prepare a manifests directory, see below
  3. Run ezops

Options

  • --dry-run, run without actually apply any changes.
  • --kubeconfig or KUBECONFIG, specify path to kubeconfig file
  • KUBECONFIG_BASE64, base64 encoded kubeconfig file content

Layout of Manifests Directory

  • Each top-level directory stands for a namespace
  • Every manifest file in that directory, will be applied to that namespace

For example:

namespace-a/
  workload-aa.yaml
  workload-ab.jsonnet
  workload-ac.json
namespace-b/
  workload-ba.yaml
  workload-bb.jsonnet
  workload-bc.json

Helm Support

  • Put a Helm Chart to top-level directory _helm
  • Create values file in namespace directory, with naming format [RELEASE_NAME].[CHART_NAME].helm.yaml

For example:

_helm/
  ingress-nginx/
    Chart.yaml
    values.yaml
    templates/
      ...
kube-system/
  main.ingress-nginx.helm.yaml

ezops will create or update a release named main, using chart _helm/ingress-nginx, and values file kube-system/primary.ingress-nginx.helm.yaml

ezops also support Helm values file in JSONNet

Credits

GUO YANKE, MIT License

Documentation

Index

Constants

View Source
const (
	SubdirHelm = "_helm"
)

Variables

View Source
var (
	SuffixHelmValuesJSONNet = ".helm.jsonnet"

	SuffixesYAML       = FileSuffixes{".yaml", ".yml"}
	SuffixesJSON       = FileSuffixes{".json"}
	SuffixesJSONNet    = FileSuffixes{".jsonnet"}
	SuffixesHelmValues = FileSuffixes{".helm.yaml", ".helm.yml", SuffixHelmValuesJSONNet}
)

Functions

func ConvertJSONNetFileToYAML

func ConvertJSONNetFileToYAML(file string, namespace string) (outFile string, err error)

func CreateReleaseID

func CreateReleaseID(namespace string, name string) string

func CreateResourceID

func CreateResourceID(namespace string, object Object) string

Types

type Chart

type Chart struct {
	Name     string
	Path     string
	Checksum string
}

type FileSuffixes

type FileSuffixes []string

func (FileSuffixes) Match

func (fs FileSuffixes) Match(path string) bool

type KubernetesClientSource

type KubernetesClientSource struct {
	InCluster      bool
	KubeconfigPath string
	TemporaryDir   string
}

func ResolveKubernetesClient

func ResolveKubernetesClient(optKubeconfig string) (source KubernetesClientSource, err error)

func (KubernetesClientSource) Build

func (s KubernetesClientSource) Build() (client *kubernetes.Clientset, err error)

func (KubernetesClientSource) CleanUp

func (s KubernetesClientSource) CleanUp()

type List

type List struct {
	APIVersion string            `json:"apiVersion"`
	Kind       string            `json:"kind"`
	Items      []json.RawMessage `json:"items"`
}

func NewList

func NewList(items []json.RawMessage) *List

func (List) Valid

func (l List) Valid() bool

type LoadOptions

type LoadOptions struct {
	Charts map[string]Chart
}

type LoadResult

type LoadResult struct {
	Releases     []Release
	Resources    []Resource
	ResourcesExt []Resource
}

func Load

func Load(root string, namespace string, opts LoadOptions) (result LoadResult, err error)

type Object

type Object struct {
	Metadata   ObjectMeta `json:"metadata"`
	Kind       string     `json:"kind"`
	APIVersion string     `json:"apiVersion"`
}

type ObjectMeta

type ObjectMeta struct {
	Name      string `json:"name,omitempty"`
	Namespace string `json:"namespace,omitempty"`
}

type Release

type Release struct {
	ID         string
	Name       string
	Chart      Chart
	ValuesFile string
	Checksum   string
}

type Resource

type Resource struct {
	ID        string
	Namespace string
	Object    Object
	Raw       json.RawMessage
	Checksum  string
	Path      string
}

type ScanResult

type ScanResult struct {
	Charts     map[string]Chart
	Namespaces []string
}

func Scan

func Scan(root string) (result ScanResult, err error)

Directories

Path Synopsis
cmd
pkg

Jump to

Keyboard shortcuts

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