kubestorm

command module
v0.1.2 Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2020 License: MIT Imports: 11 Imported by: 0

README

Go Codecov Go Report Card Release

kubestorm

  • A RESTful API to interact with Kubernetes resources
  • Easy to customize and integrate with UI/Chatbot/Automation

It consists of 3 main components:

  • Backend - Rest API (Go)
  • Frontend (Vue.js) (BEING DEVELOPED)
  • Persistent Layer to store configurations

Docs

swag init

Development

Contributions are welcome via PRs with Issues!

Use Go Module

export GO111MODULE=on

Start the API locally

# Clone the repository
git clone https://github.com/supernova106/kubestorm.git
cd kubestorm/
go run main.go

Or using the pre-built binary

./kubestorm

Usage

Generate Auth TOKEN for your Kubernetes cluster
  • create the following kubestorm.yaml
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
  name: kubestorm-role
rules:
  - apiGroups: ["", "extensions", "apps", "batch", "events", "resourcequotas"]
    resources: ["*"]
    verbs: ["list", "watch", "get"]
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: kubestorm-user
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1beta1
kind: ClusterRoleBinding
metadata:
  name: kubestorm-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: kubestorm-role
subjects:
  - kind: ServiceAccount
    name: kubestorm-user
    namespace: kube-system
kubectl apply -f kubestorm.yaml

Get server URL

export CURRENT_CONTEXT=$(kubectl config current-context) && export CURRENT_CLUSTER=$(kubectl config view -o go-template="{{\$curr_context := \"$CURRENT_CONTEXT\" }}{{range .contexts}}{{if eq .name \$curr_context}}{{.context.cluster}}{{end}}{{end}}") && echo $(kubectl config view -o go-template="{{\$cluster_context := \"$CURRENT_CLUSTER\"}}{{range .clusters}}{{if eq .name \$cluster_context}}{{.cluster.server}}{{end}}{{end}}")

Get serverCADataString

echo $(kubectl get secret -n kube-system -o go-template='{{index .data "ca.crt" }}' $(kubectl get sa kubestorm-user -n kube-system -o go-template="{{range .secrets}}{{.name}}{{end}}"))

Get token

echo $(kubectl get secret -n kube-system -o go-template='{{index .data "token" }}' $(kubectl get sa kubestorm-user -n kube-system -o go-template="{{range .secrets}}{{.name}}{{end}}")) | base64 --decode
CRUD cluster auth

Execute the following script to add cluster

export CLUSTER_NAME="foo"

# replace with actual URL of kubestorm
./scripts/add_cluster.sh "${CLUSTER_NAME}" http://localhost:8080

# get auth
curl --location --request GET "http://localhost:8080/api/v1/auth/${CLUSTER_NAME}"

# delete
curl --location --request DELETE "http://localhost:8080/api/v1/auth/${CLUSTER_NAME}"
GET Kubernetes resources from a cluster
curl --location --request GET "http://localhost:8080/api/v1/resources?cluster=${CLUSTER_NAME}&type=nodes"

Release

  • The release process is automated via git tagging.
  • Check out the .github/workflows/goreleaser.yml

Todo

  • Add more unit testings
  • Develop Simple Dashboard for Kubernetes
  • Support S3 to store configurations
  • Slack Chatbot integration

Contributors

  • Binh Nguyen

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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