Coder Social home page Coder Social logo

mgoltzsche / k8spkg Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 0.0 10.38 MB

A Kubernetes component lifecycle manager CLI (deprecated in favour of kpt)

License: Apache License 2.0

Makefile 2.09% Go 97.91%
kubernetes kustomize package rollout k8s continuous-delivery lifecycle lifecycle-management

k8spkg's Introduction

k8spkg Build Status Go Report Card

A wrapper around kubectl to transform, deploy, undeploy and retrieve Kubernetes manifests as a deployment unit waiting for the respective task to be completed. k8spkg accepts manifest files and kustomizations like kubectl.

Features

  • Maintain a group of Kubernetes resources as package using labels (app.kubernetes.io/part-of, k8spkg.mgoltzsche.github.com/namespaces).
  • Add common labels to a manifest's resources (using kustomize).
  • Wait for conditions (ready, available, ...) of a manifest's resources.
  • List installed packages: Packages are visible within their resources' namespace(s) only as long as they don't have cluster-scoped resources as well.
  • Delete resources by package name or manifest and wait until they are deleted.
  • kustomization source support.

Requirements

Usage

Command Description
manifest {-f SRC|-k SRC} [--name <PKG>] [--namespace <NS>] [--timeout <DURATION>] Prints a merged and labeled manifest
apply {-f SRC|-k SRC} [--name <PKG>] [--namespace <NS>] [--timeout <DURATION>] [--prune] Installs or updates the provided source as package and waits for the rollout to succeed. --prune deletes all resources labeled with the package name that do not appear within the source from the cluster - should be used carefully.
delete {-f SRC|-k SRC|PKG} [--namespace <NS>] [--timeout <DURATION>] Deletes the identified resources from the cluster and awaits their deletion. A package's resources in other namespaces that are referred to (label) within cluster-scoped resources are deleted as well.
list [--all-namespaces|--namespace <NS>] [--timeout <DURATION>] Lists the installed packages that are visible within the namespace. Other namespaces are not queried as long as --all-namespaces is not enabled. However packages of cluster-scoped resources and their referenced (label) namespaces are listed as well.

Examples

Print labeled manifest of the deployment unit cert-manager:

$ k8spkg manifest --name cert-manager -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.7/deploy/manifests/cert-manager.yaml
<YAML output>

Label and deploy cert-manager and a namespaced issuer afterwards:

k8spkg apply --name cert-manager -f https://raw.githubusercontent.com/jetstack/cert-manager/release-0.7/deploy/manifests/cert-manager.yaml &&
k8spkg apply --name cert-manager-ca-issuer -f ca-issuer.yaml

Please note that this does not (yet?!) work with kubectl apply since it does not wait for resources to be ready (cert-manager's APIService must accept the Issuer) and there is no option or other generic kubectl command to wait for such a state based on a given manifest. Fortunately kubectl rollout and kubectl wait serve this purpose but require resource names and type-dependent options which k8spkg provides.

List the installed packages from within the default namespace:

$ k8spkg list
PACKAGE                   NAMESPACES
cert-manager              cert-manager,kube-system

List the installed packages wtthin cert-manager namespace:

$ k8spkg list -n cert-manager
PACKAGE                   NAMESPACES
cert-manager              cert-manager,kube-system
cert-manager-ca-issuer    cert-manager

Label and deploy a kustomize package:

k8spkg apply --name hello-world -k github.com/kubernetes-sigs/kustomize//examples/helloWorld?ref=v2.1.0

Install or update a package in another namespace:

k8spkg apply -n mynamespace --name hello-world --prune -k github.com/kubernetes-sigs/kustomize//examples/helloWorld?ref=v2.1.0

Delete a previously installed package:

k8spkg delete -n cert-manager cert-manager-ca-issuer

Install

Download and install the latest k8spkg release (static linux amd64):

curl -L https://github.com/mgoltzsche/k8spkg/releases/latest/download/k8spkg > k8spkg
chmod +x k8spkg
sudo mv k8spkg /usr/local/bin/k8spkg

Build

Install/update with Go:

go get -u github.com/mgoltzsche/k8spkg

or run a dockerized k8spkg build:

git clone https://github.com/mgoltzsche/k8spkg
cd k8spkg && make
sudo mv k8spkg /usr/local/bin/

The project can be opened in a containerized LiteIDE using make ide.

License

k8spkg is licensed under Apache License 2.0. Some of the 3rd party modules in the vendor directory are licensed under different Open Source conditions (see LICENSE files).

k8spkg's People

Contributors

mgoltzsche avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.