naml

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 22 Imported by: 2

README

Go Reference

Not another markup language.

Replace Kubernetes YAML with raw Go!

Say so long 👋 to YAML and start using the Go 🎉 programming language to represent and deploy applications.

Take advantage of all the lovely features of Go.

Test your code directly in local Kubernetes using kind.

Get your application directly into Go instead of YAML and use it in controllers, operators, CRs/CRDs easily. Use the Go compiler to your advantage.

Quickstart

Check out the examples GitHub organization.

  • simple basic CLI example.
  • full CLI example with custom commands and flags.
Implement Deployable

As long as there is a Go system that implements this interface it can be used with naml. See examples for how to include an implementation in your project.

// Deployable is used to deploy applications.
type Deployable interface {

	// Install will attempt to install in Kubernetes
	Install(client *kubernetes.Clientset) error

	// Uninstall will attempt to uninstall in Kubernetes
	Uninstall(client *kubernetes.Clientset) error

	// Meta returns the Kubernetes native ObjectMeta which is used to manage applications with naml.
	Meta() *v1.ObjectMeta
}

About

This is a framework for infrastructure teams who need more than just conditional manifests.

This allows teams to start encapsulating, managing, and testing their applications in raw Go.

Teams can now buid controllers, operators, and custom toolchains using reliable, testable, and scalable Go.

The philosophy

The bet here is that any person confident in managing YAML for Kubernetes can also be equally as confident managing Go for Kubernetes.

The feature add is that no matter how good our YAML management tools get, they will never be as good as just plain Go when it comes to things like syntax checking, testing, shipping, and flexibility.

Nothing fancy

Feel free to fork this repository and begin using it for your team. There isn't anything special here. 🤷‍♀ We use the same client the rest of Kubernetes does.

❎ No new tools.

❎ No charts.

❎ No templating at runtime.

❎ No vague error messages.

❎ No more YAML guessing/checking.

✅ Just Go. 🎉

Features

✨ There is not a single .yaml file in this entire repository. ✨

  • Express applications in 🎉 Go instead of YAML.
  • Use the Go compiler to check your syntax.
  • Write real tests 🤓 using Go to check and validate your deployments.
  • Test your applications in Kubernetes using kind.
  • Define custom installation logic. What happens if it fails?
  • Define custom application registries. Multiple apps of the same flavor? No problem.
  • Use the latest client (the same client the rest of Kubernetes uses).

Getting Started

Check out the examples GitHub organization.

  • simple basic CLI example.
  • full CLI example with custom commands and flags.

Documentation

Index

Constants

View Source
const (
	KubeconfigEnvironmentalVariable = "KUBECONFIG"
	KubeconfigDefaultDirectory      = ".kube"
	KubeconfigDefaultFile           = "config"
)
View Source
const (
	// TestClusterName is used to identify the test cluster with Kind.
	TestClusterName string = "namltestcluster"
)

Variables

View Source
var Version string

Version is this specific version on naml

Functions

func AddRPC

func AddRPC(path string) error

AddRPC will attempt to add a remote RPC server to the current runtime.

func AllInit

func AllInit(kubeConfigPath string, verbose bool, with []string) error

AllInit is the "constructor" for every command line flag. This is how we use naml -w to include sub-namls

func Banner()

func BusyboxDeployment

func BusyboxDeployment(name string) *v1.Deployment

BusyboxDeployment is useful for quick testing and debugging. This is broken by design.

func Client

func Client() (*kubernetes.Clientset, error)

Client is used to authenticate with Kubernetes and build the Kube client for the rest of the program.

func ClientFromFlags

func ClientFromFlags(apiUrl, kubeConfigPath string) (*kubernetes.Clientset, error)

ClientFromFlags will plumb well-known command line flags through to the kubeconfig

func ClientFromPath

func ClientFromPath(kubeConfigPath string) (*kubernetes.Clientset, error)

ClientFromPath is used to authenticate with Kubernetes and build the Kube client for the rest of the program given a specific kube config path.

Useful for testing.

func I32p

func I32p(i int32) *int32

func I64p

func I64p(i int64) *int64

func Install

func Install(app Deployable) error

Install is used to install an application in Kubernetes

func List

func List()

List the naml package information in stdout

func Register

func Register(app Deployable)

Register an application with naml

func RegisterAndError

func RegisterAndError(app Deployable) error

func RegisterAndExit

func RegisterAndExit(app Deployable)

RegisterAndExit will register the app or exit with an error message in stdout

func RegisterRemoteApplications

func RegisterRemoteApplications() error

RegisterRemoteApplications will call list() on all remote RPC servers and register the applications as pointers on the remote.

func Registry

func Registry() map[string]Deployable

Registry will return the registry

func RunCommandLine

func RunCommandLine() error

RunCommandLine is the global NAML command line program.

Use this if you would like to use the built in NAML command line interface.

func RunCommandLineAndExit

func RunCommandLineAndExit()

func RunCommandLineWithOptions

func RunCommandLineWithOptions() error

RunCommandLineWithOptions is here so we can default values in RunCommandLine() that we would want to pass in here later (tests, etc)

func RunRPC

func RunRPC() error

RunRPC will run in RPC mode.

TODO: Nóva to come add security auth and validation to our RPC

func Stringp

func Stringp(i string) *string

func TestClusterKubeConfigPath

func TestClusterKubeConfigPath() string

TestClusterKubeConfigPath will export the kubeconfig path to this directory to use for the client in the tests.

func TestClusterStart

func TestClusterStart() error

TestClusterStart can be used to start the test cluster in the TestMain() function.

func TestClusterStop

func TestClusterStop() error

TestClusterStop can be used to stop the test cluster in the TestMain() function.

func Uninstall

func Uninstall(app Deployable) error

Uninstall is used to uninstall an application in Kubernetes

Types

type Deployable

type Deployable interface {

	// Install will attempt to install in Kubernetes
	Install(client *kubernetes.Clientset) error

	// Uninstall will attempt to uninstall in Kubernetes
	Uninstall(client *kubernetes.Clientset) error

	// Meta returns the Kubernetes native ObjectMeta which is used to manage applications with naml.
	Meta() *v1.ObjectMeta

	// Description returns the application description
	Description() string
}

Deployable is an interface that can be implemented for deployable applications.

func Find

func Find(name string) Deployable

Find an application by name

type RPCApplication

type RPCApplication struct {
	// Name is the name of the remote application
	AppName string

	// Remote is the associated remote RPC server
	Remote *RPCPointer

	// AppDescription is the application description
	AppDescription string

	// AppVersion is the application version
	AppVersion string
}

RPCApplication is the pointer in the parent process to the child process internal application.

func (*RPCApplication) Description

func (c *RPCApplication) Description() string

func (*RPCApplication) Install

func (c *RPCApplication) Install(clientset *kubernetes.Clientset) error

Install is the remote application install wrapper.

func (*RPCApplication) Meta

func (c *RPCApplication) Meta() *v1.ObjectMeta

func (*RPCApplication) Uninstall

func (c *RPCApplication) Uninstall(clientset *kubernetes.Clientset) error

type RPCError

type RPCError struct {
	Message string
}

RPCError is when something goes wrong over the RPC

type RPCPointer

type RPCPointer struct {
	Message string
	Addr    string
}

RPCPointer is a pointer that allows us to connect to a remote RPC server

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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