syngonizer

package module
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2019 License: MIT Imports: 8 Imported by: 0

README

SynGoNizer

Go Report Card

Watch and sync files from your local env to one or more running containers on a Kubernetes infrastructure.

Note: This is a WiP. This first version uses kubectl to connect to the running kubernetes cluster. In future it will be replaced with a better implementation, based on the official kubernetes client API. But this is enough for a raining Sunday.

Motivation

  • I work on a codebase written in a scripting language that interacts with a lot of different services in a kubernetes environment.

  • It is not possible (or better, not very convenient) run the application locally.

  • I want to save a file (or delete, or remove, or ...) and be sure it will be sync in all the containers where this file is expected to be. In this way I can see "real-time" changes in the running application (the beauty of scripting languages!).

  • I do not want to build a new container image and deploy it for each little change in my code.

  • I do not want to work from inside a running container, e.g. via kubectl -exec (I could have a deployment with several running replicates and I need my changes locally).

  • Moreover, I need a fun case to improve my Golang skills :-)

Usage

  go get github.com/frncscsrcc/syngonizer
  go build src/github.com/frncscsrcc/syngonizer/cmd/syngonizer.go
  ./syngonizer.go configuration.json

Config example

{
  "global": {
    // Events watch time (sec)
    "event-listen-iterval": 0.50,
    // How often get an updated list of pods for the required namespace (sec)
    "update-pod-list-interval": 20,
    // Kube namespace
    "namespace": "default",
    // kubectl bin
    "kubectl-path": "/snap/bin/microk8s.kubectl",
    // Allow to sync if namespace = "production"
    "allow-production": false,
    // Die in case of errors
    "die-if-error": false
  },
  "folders": [
    {
      // Absolute path for a watched folder
      "local-root" : "/home/project/appACode/",
      // Remote path on the container (optional)
      "remote-root" : "/container/folder/",
      // "app" label to be used (better selector in next version)
      "apps" : ["appA1", "appA2"]
    },
    {
      "local-root" : "/home/project/commonCode/",
      "remote-root" : "/container/folder/",
      "apps" : ["appA1", "appA2", "appB1"]
    },
    {
      "local-root" : "/home/project/appBCode/",
      "apps" : ["appB1"]
    }    
  ]
}

Documentation, configuration examples and hopefully unit tests will be added ASAP.

Made with <3 from and enthusiastic (and still naive) Go developer.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadConfig

func LoadConfig(path string) (config.Config, error)

LoadConfig ...

func Watch

func Watch(config config.Config) error

Watch ...

Types

type WatchFolder

type WatchFolder struct {
	// contains filtered or unexported fields
}

WatchFolder ...

func (*WatchFolder) String

func (wf *WatchFolder) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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