• Stars
    star
    1,256
  • Rank 37,419 (Top 0.8 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 3 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Convert Kubernetes YAML to Golang

Go Reference

Not Another Markup Language.


Please help me become an independent programmer by donating directly below.

ko-fi


NAML is a Go library and command line tool that can be used as a framework to develop and deploy Kubernetes applications.

Replace Kubernetes YAML with raw Go!

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

Kubernetes applications are complicated, so lets use a proper Turing complete language to reason about them.

Take advantage of all the lovely features of Go (Syntax highlighting, Cross compiling, Code generation, Documentation)

Test your code directly in local Kubernetes using kind. Yes you can really deploy your applications to Kubernetes.

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.

Convert YAML to Go

cat deploy.yaml | naml codify > main.go

Turn existing YAML into formatted and syntactically correct Go that implements the Deployable interface.

mkdir out

# Get started quickly with all objects in a namespace
kubectl get all -n default -o yaml | naml codify > out/main.go

# Overload the template with your information
cat app.yaml | naml codify \
  --author-name="Charlie" \
  --author-email="<[email protected]>" > out/main.go
  
# Combine files in one command
printf "\n\n---\n\n" | cat file1.yaml - file2.yaml - file3.yaml | naml codify > out/main.go

Then compile and run your application against Kubernetes.

cd out
naml build -o app
./app -o yaml
./app install 
./app uninstall

Use make help for more. Happy coding 🎉.

Example Projects

There is a "repository" of examples to borrow/fork:

The Deployable Interface

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 an interface that can be implemented
// for deployable applications.
type Deployable interface {

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

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

// Meta returns a NAML Meta structure which embed Kubernetes *metav1.ObjectMeta
Meta() *AppMeta

// Objects will return the runtime objects defined for each application
Objects() []runtime.Object
}

In order to get the raw Kubernetes objects in Go without installing them anywhere, you pass in nil in place of an authenticated Kubernetes Clientset.

Then you can access the objects in memory.

    app.Install(nil)
    objects := app.Objects()

Nothing fancy

There isn't anything special here. 🤷‍♀ We use the same client the rest of Kubernetes does.

No new complex tools.

No charts.

No templating at runtime.

No vague error messages.

No more YAML guessing/checking.

Just Go. 🎉

Features

  • 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? What about logical concerns at runtime?
  • Define custom application registries. Multiple apps of the same flavor? No problem.
  • Use the latest client (the same client the rest of Kubernetes uses).

More Repositories

1

boopkit

Linux eBPF backdoor over TCP. Spawn reverse shells, RCE, on prior privileged access. Less Honkin, More Tonkin.
C
1,540
star
2

xpid

Linux Process Discovery. C Library, Go bindings, Runtime.
Go
217
star
3

4n6

Linux Process Discovery. C Library, Go bindings, Runtime.
Go
178
star
4

kaar

Kubernetes Application Archive
Go
151
star
5

krex

Kubernetes Resource Explorer
Go
134
star
6

lolgopher

Rainbow Writer implementation for Golang
Go
113
star
7

terraformctl

Running Terraform in Kubernetes as a controller
Go
88
star
8

q

Surface Linux networking metrics with eBPF
Rust
87
star
9

rust-nova

Rust template repository.
Rust
73
star
10

kops-demo

Material from speaking on Kubernetes kops
Shell
65
star
11

hack

Kubernetes security and vulnerability tools and utilities.
Shell
56
star
12

kush

Kubernetes Unhinged Shell 😎
Go
46
star
13

klone

Taking you from a git repository to development in seconds
Go
45
star
14

nivenly.com

Source code for nivenly.com
HTML
38
star
15

tcpjack

TCP Instrumentation
C
38
star
16

knobs

Kubernetes Native Open Broadcasting Software
Go
37
star
17

logger

Simple logger (with rainbows) for Go
Go
36
star
18

falco-trace

Falco Running with Ptrace(2) for Kernel Events
Shell
36
star
19

splain

Fantastic manuals for the Unix like operating systems
Roff
35
star
20

novix

kris nóva userspace and kernel tools for the Novix operating system
C
35
star
21

photoprism-client-go

Go client for the Photoprism Application
Go
32
star
22

twinx

A twitch focused command line tool for producing, archiving and managing live stream content. Built for Linux.
Go
26
star
23

home

My entire hacker toolkit ready for to run on a vanilla Arch Linux installation.
Shell
23
star
24

heresafe

Text someone once you connect to a WiFi network.
Python
22
star
25

krust

Kubernetes Client Rust
Rust
22
star
26

nginx-proxy-analysis

A small research project aimed at understanding the behaviour of a simple nginx reverse proxy given various upstream server conditions.
C
21
star
27

stateful-app

A great stateful application
Go
20
star
28

go-nova

Go template repository.
Go
18
star
29

bashernetes

A Kubernetes implementation in bash (srsly)
17
star
30

hachyderm.io

Source code for hachyderm.io
17
star
31

double-slit-experiment

Identify containers at runtime and observe them. No container runtime required. Read only access to the kernel.
Go
16
star
32

alice

My main kubernetes toolchain and configuration.
Shell
15
star
33

Makefile

Makefile example. All Makefiles should have "help"
Makefile
15
star
34

.net

Compiled Works: Computer Science, Engineering, Analysis, Research
HTML
14
star
35

kubernetes-freebsd

Notes, Documentation, and Convenience scripts for running Kubernetes on FreeBSD
Shell
13
star
36

prine

Hacker themed Hugo theme based on Nivenly.com
HTML
13
star
37

cloud-native-infrastructure-demo

Demo content for cloud native infrastructure talks
HCL
12
star
38

kryptid

Kubernetes on Arch Linux
Shell
11
star
39

aurora

Generate rust command line executables from gRPC protobuf services.
Rust
10
star
40

spark-cluster-api-operator

Use Kubernetes to autoscale your spark clusters.
Go
10
star
41

go-plugin-demo

Notes from my presentation on Go plugins in 1.8
Go
10
star
42

bjorno

Go HTTP server built for runtime interpolation with text/template.
Go
9
star
43

viz

Visualize TCP connections in a distributed network.
9
star
44

cupernetes

The Common Unix Printing System for Kubernetes
C
8
star
45

kscan

A simple tool to exploit unsecure Kubernetes clusters
8
star
46

gomfg

The best way to start a new Go project
7
star
47

rebrandly-go-sdk

A Go SDK for the Rebrandly API
Go
7
star
48

skrape

Snapshot the internet from a shell.
Shell
7
star
49

SYN-spoof

A SYN spoof penetration test written and compiled on FreeBSD 10+
C
7
star
50

kubernetes-workshop-old

Welcome to Kubernetes! We love you!
6
star
51

thenovashow

Live Streaming repository for all things twitch.tv/krisnova
6
star
52

twitter-watch

Watching Twitter, because why not?
Shell
6
star
53

kssh

kSSH is a simple utility for managing SSH hosts and tracking aliases in an SSH config file.
Python
6
star
54

c-container

Container-y things in C
C
5
star
55

kenv

kenv - Kris' Environment - My name is Kris. This is where I store my environment code.
Emacs Lisp
5
star
56

barff

BPF Application Relay For Falco (BARFF) 🤮
C
5
star
57

certsar

For those "Special TLS Encryption Operations"
C
5
star
58

farm

Falco on ARM
C++
4
star
59

brand

Official Kris Nóva Brand and Branding Guidelines
CSS
4
star
60

go-azure

Go SDK for Microsoft's Azure Cloud
Go
4
star
61

forfucksake

A ZFS Distributed Filesystem Service (ZFFS)
Shell
4
star
62

pqueue

Concurrent persistent message queue written in Go
Go
3
star
63

halp

Emergency iridium communication relay.
Go
3
star
64

gorpc

Gorpsy. Remote procedure call for local linux hosts written in Go.
Go
3
star
65

kournalctl

Read only system logs within a Kubernetes pod
Shell
3
star
66

todo

Public facing list of neverending project ideas.
3
star
67

bjorn

official github repository for fjalljökulbjörn nóvasson (björn)
3
star
68

legendary-apache-kubernetes

Running Apache Spark and Apache Kafka on Kubernetes
3
star
69

aur-falco

AUR Installer for Falco - Runtime Security
Shell
3
star
70

novaarchive

Commonly used go convenience tools and libraries
Go
3
star
71

go-kvm

A KVM Library written in Go
3
star
72

pen

Penetration tools.
Shell
3
star
73

homework

Nova doing hacks for interviews
Go
3
star
74

puffin-operator

Example operator based on puffins
Go
3
star
75

deva

Developer Advocate CLI Awesomeness
3
star
76

jails-container-runtime

FreeBSD Jails wrapper that implements OCI
3
star
77

anchovies

Import a Go package and start writing records. Persist data across processes based on unique machines.
Go
3
star
78

pacfem

Archlinux user repository package manager written in Go
2
star
79

azurite

Helping developers hack on Microsoft Azure!
2
star
80

paketto

Paketto Keiretsu (Archive) Dan Kaminsky
C
2
star
81

falco-rules

My Falco Rules
2
star
82

charlie

Cloud Infrastructure Testing Library (Under construction)
Go
2
star
83

kind-test

Use Kubernetes in Docker to write Kubernetes unit tests using the idiomatic Go testing suite
Go
2
star
84

lit

Print in-memory structs as syntactically correct Go literals.
2
star
85

load-test

Load testing a single host using only SSH and bash
Shell
2
star
86

go-service

A systemd service library written in Go
2
star
87

terrapin

Kubernetes Control Station built on Cluster API
JavaScript
2
star
88

mrow

Handy functions I am tired of re-writing
2
star
89

bbb

Securely manage Linux features from Kubernetes.
2
star
90

kubeflow-with-heptio

Working repository for our presentation on running Kubeflow with Heptio tools on the backend
1
star
91

tilda

~
1
star
92

net-snoop

A small network snooping library that is used on nivenly.com
1
star
93

space

My GitHub space.
1
star
94

c-kit

A collection of tools written in C wrapped up in a Go command line tool.
1
star
95

thenovadiary

Automation for the @thenovadiary Twitter account
Go
1
star
96

rusty-webserver

Just building a containerized web server in Rust
1
star
97

WebApplication

Primary Public Facing Repository
CSS
1
star
98

kgit

External git configuration management and enforcement.
Python
1
star
99

zomg-audit

A repository that contains software to hack a Kubernetes cluster to turn on dynamic auditing because why not?
1
star
100

zoosb

ZFS Pool manager for USB block devices
1
star