Compare commits
9 Commits
Author | SHA1 | Date |
---|---|---|
Martyn | 3a1ad5325a | |
Martyn | f31422e6b3 | |
Martyn | 6e27e9716a | |
Martyn | 4077775bb7 | |
Martyn | 00915f3420 | |
Martyn | 7729059d4c | |
Martyn | 09a0523b3d | |
Martyn | 4a89a5ccfe | |
Martyn | 4db90dd22d |
2
Makefile
2
Makefile
|
@ -16,4 +16,4 @@ deps:
|
|||
|
||||
dist:
|
||||
mkdir -p bin || true
|
||||
cd cmd && go build ${LDFLAGS_STATIC} -installsuffix cgo -o ../bin/helm-import .
|
||||
cd cmd && go build ${LDFLAGS_STATIC} -installsuffix cgo -o ../bin/helm-import-linux-x64 .
|
||||
|
|
65
README.md
65
README.md
|
@ -1,5 +1,64 @@
|
|||
# helm-import
|
||||
|
||||
A tool to take a deployed set of kubernetes resources and turn them into a helm release.
|
||||
|
||||
Only works with helm3 > 3.2.0
|
||||
A tool to take a deployed set of kubernetes resources and turn them into a helm release.
|
||||
|
||||
Only works with helm3 > 3.2.0
|
||||
|
||||
Only compiles with Go < 1.15
|
||||
|
||||
And it's a pain to cross-compile, and my ci is currently broken
|
||||
|
||||
You can add jq commands to tweak the generation.
|
||||
|
||||
You run it from the chart folder (the one with `Chart.yaml`) in it
|
||||
|
||||
It's fairly opinionated but that can be turned off.
|
||||
|
||||
There's some kinda hacky stuff in the code related to json->yaml->helm stuff.
|
||||
|
||||
so... erm here's a docker command that worked for me :
|
||||
|
||||
```
|
||||
docker run -v $(pwd):/context -v $HOME/.kube:/root/.kube --rm -it -w /context/ imartyn/helm-import /helm-import -namespace some-namespace -deployment some-deployment
|
||||
```
|
||||
|
||||
and here's the help screen :
|
||||
```
|
||||
Usage of helm-import:
|
||||
-configmap value
|
||||
configmap to import into the helm chart (can be specified multiple times)
|
||||
-configmapJqCommands value
|
||||
extra jq commands to apply to configmaps
|
||||
-deployment value
|
||||
deployment to import into the helm chart (can be specified multiple times)
|
||||
-deploymentJqCommands value
|
||||
extra jq commands to apply to deployments
|
||||
-globalJqCommands value
|
||||
extra jq commands to apply to all k8s objects
|
||||
-ingress value
|
||||
ingress to import into the helm chart (can be specified multiple times)
|
||||
-ingressJqCommands value
|
||||
extra jq commands to apply to ingresses
|
||||
-kubeconfig string
|
||||
(optional) absolute path to the kubeconfig file (default "/home/martyn/.kube/config")
|
||||
-lessopinions
|
||||
just import the objects into files, don't get opinionated
|
||||
-namespace string
|
||||
namespace to work in (default "default")
|
||||
-nobuiltinmods
|
||||
don't do the built-in modifications, only ones passed in by user
|
||||
-secret value
|
||||
secret to import into the helm chart (can be specified multiple times)
|
||||
-secretJqCommands value
|
||||
extra jq commands to apply to secrets
|
||||
-service value
|
||||
service to import into the helm chart (can be specified multiple times)
|
||||
-serviceJqCommands value
|
||||
extra jq commands to apply to services
|
||||
|
||||
```
|
||||
|
||||
TODO:
|
||||
- [ ] label the resources
|
||||
- [ ] make ci work again
|
||||
- [ ] cross-compile, now I know it was a go-1.15 issue first time
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
kind: pipeline
|
||||
type: docker
|
||||
type: kubernetes
|
||||
name: linux-amd64-taggedver
|
||||
|
||||
platform:
|
||||
|
@ -8,8 +8,10 @@ platform:
|
|||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang
|
||||
image: golang:1.14-buster
|
||||
commands:
|
||||
- apt-get update
|
||||
- apt-get install -y libjq-dev
|
||||
- pwd
|
||||
- mkdir -p /go/src/git.martyn.berlin/martyn
|
||||
- ln -s /drone/src /go/src/git.martyn.berlin/martyn/helm-import
|
||||
|
@ -21,6 +23,7 @@ steps:
|
|||
image: plugins/docker:18
|
||||
settings:
|
||||
auto_tag: true
|
||||
debug: true
|
||||
auto_tag_suffix: linux-amd64
|
||||
dockerfile: build/package/Dockerfile
|
||||
repo: imartyn/helm-import
|
||||
|
@ -33,13 +36,26 @@ steps:
|
|||
- push
|
||||
- tag
|
||||
|
||||
- name: release
|
||||
image: plugins/gitea-release
|
||||
settings:
|
||||
api_key:
|
||||
from_secret: gitea_release_token
|
||||
base_url: https://git.martyn.berlin/
|
||||
files:
|
||||
- bin/helm-import-linux-x64
|
||||
title: Built in CI
|
||||
prerelease: true
|
||||
when:
|
||||
event: tag
|
||||
|
||||
trigger:
|
||||
ref:
|
||||
- refs/tags/v*
|
||||
|
||||
---
|
||||
kind: pipeline
|
||||
type: docker
|
||||
type: kubernetes
|
||||
name: linux-amd64-devel-main
|
||||
|
||||
platform:
|
||||
|
@ -48,8 +64,10 @@ platform:
|
|||
|
||||
steps:
|
||||
- name: build
|
||||
image: golang
|
||||
image: golang:1.14-buster
|
||||
commands:
|
||||
- apt-get update
|
||||
- apt-get install -y libjq-dev
|
||||
- pwd
|
||||
- mkdir -p /go/src/git.martyn.berlin/martyn
|
||||
- ln -s /drone/src /go/src/git.martyn.berlin/martyn/helm-import
|
||||
|
|
|
@ -14,5 +14,5 @@ COPY Makefile /go/src/git.martyn.berlin/martyn/helm-import/
|
|||
RUN cd /go/src/git.martyn.berlin/martyn/helm-import/; make deps && make dist
|
||||
|
||||
FROM alpine:3.12
|
||||
COPY --from=builder /go/src/git.martyn.berlin/martyn/helm-import/bin/helm-import /
|
||||
COPY --from=builder /go/src/git.martyn.berlin/martyn/helm-import/bin/helm-import-linux-x64 /helm-import
|
||||
COPY --from=builder /usr/lib/libjq.* /usr/lib/
|
||||
|
|
|
@ -150,6 +150,8 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
y = ""
|
||||
fileString = ""
|
||||
for _, service := range services {
|
||||
serviceObject, err := clientset.CoreV1().Services(namespace).Get(service, metav1.GetOptions{})
|
||||
if errors.IsNotFound(err) {
|
||||
|
@ -175,6 +177,8 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
y = ""
|
||||
fileString = ""
|
||||
for _, configmap := range configmaps {
|
||||
configmapObject, err := clientset.CoreV1().ConfigMaps(namespace).Get(configmap, metav1.GetOptions{})
|
||||
if errors.IsNotFound(err) {
|
||||
|
@ -200,6 +204,8 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
y = ""
|
||||
fileString = ""
|
||||
for _, secret := range secrets {
|
||||
secretObject, err := clientset.CoreV1().Secrets(namespace).Get(secret, metav1.GetOptions{})
|
||||
if errors.IsNotFound(err) {
|
||||
|
@ -225,6 +231,8 @@ func main() {
|
|||
}
|
||||
}
|
||||
|
||||
y = ""
|
||||
fileString = ""
|
||||
for _, ingress := range ingresses {
|
||||
ingressObject, err := clientset.ExtensionsV1beta1().Ingresses(namespace).Get(ingress, metav1.GetOptions{})
|
||||
if errors.IsNotFound(err) {
|
||||
|
|
Loading…
Reference in New Issue