Coder Social home page Coder Social logo

segence / rest-layer-kubernetes-configmap Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 1.0 14 KB

A backend to REST Layer that stores configuration in a Kubernetes ConfigMap.

Go 100.00%
api go golang rest-api storage-backend kubernetes kubernetes-configmaps

rest-layer-kubernetes-configmap's Introduction

REST Layer Kubernetes ConfigMap Backend

A backend to REST Layer that stores configuration in a Kubernetes ConfigMap.

Further reading about ConfigMaps:

See examples/main.go for usage example.

Feature overview

  • Offers CRUD-style REST API functionality
  • Can manage ConfigMaps in the namespace it is installed to or in any other namespace (given sufficient access privileges)
  • Maintains original ConfigMap labels on Update

Building

If you're using the GB build tool, you can fetch all dependencies using the following commands:

gb vendor fetch github.com/justinas/alice
gb vendor fetch github.com/rs/cors
gb vendor fetch github.com/rs/rest-layer/resource
gb vendor fetch github.com/rs/rest-layer/rest
gb vendor fetch github.com/rs/zerolog
gb vendor fetch github.com/rs/zerolog/hlog
gb vendor fetch github.com/rs/zerolog/log
gb vendor fetch github.com/segence/rest-layer-kubernetes-configmap

Kubernetes namespaces

The library can access any Kubernetes namespace as long as it has permissions (which can be controlled through RBAC, for example).

The client has to be configred with a default Kubernetes namespace, like in the following code example:

kHandler := configmap.NewHandler(*kubernetesClient, "some-default-namespace-name")

However, the library can access ConfigMaps in other namespaces.

Creating or updating a ConfigMap in another namespace

Add the namespace field into the payload, e.g.:

{
	"id": "test-config-map",
	"namespace": "my-namespace",
	"data": {
		...
	}
}

Querying or deleting a ConfigMap in another namespace

Add the ?filter= query parameter to the end of the URL.

E.g.: /api/config-map/test-config-map?filter={namespace:"my-namespace"}

REST end-points:

Operation HTTP method URL Example payload
Create new ConfigMap POST /api/config-map {{"id": "test-config-map", "data": {"config_value": "Hello"}}}
Update existing ConfigMap PUT /api/config-map/test-config-map {{"id": "test-config-map", "data": {"config_value": "Hello2"}}}
Delete existing ConfigMap DELETE /api/config-map/test-config-map None
Find existing ConfigMap GET /api/config-map/test-config-map None

REST call examples are also available in Postman format here. Make sure to override the {{configmap-handler}} variable to the actual host where the application is running, e.g. http://localhost:8080.

Testing

The functionality can be easily tested by running Minikube locally and using the out of cluster Kubernetes client configuration.

rest-layer-kubernetes-configmap's People

Contributors

robvadai avatar

Watchers

 avatar

Forkers

diillson

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.