23 Commits

Author SHA1 Message Date
ej
009062c51a Correction statefulset ; uninstall par modules 2024-09-26 19:01:49 +00:00
admju
1b9b79c67f oci 2024-09-19 12:10:03 +00:00
admju
981ee7dce4 version 2024-09-18 19:31:18 +00:00
admju
0c35993122 Version 2024-09-18 09:09:21 +00:00
admju
3abf53ec6c version 2024-09-18 08:59:28 +00:00
admju
19790f61e2 Correction chart via repo 2024-09-18 08:41:47 +00:00
admju
ebf9d3fc6d Supp code commentée 2024-09-18 08:41:16 +00:00
admju
741d1a0ffe Correction 2024-09-18 08:40:53 +00:00
admju
8632b02f0e Aide 2024-09-18 08:40:33 +00:00
admju
95884e14d6 Doc 2024-09-13 12:57:24 +00:00
admju
bd58ac1e02 publish 2024-09-13 12:43:09 +00:00
admju
9f0218a4da Opts pour helm repo 2024-09-13 10:53:28 +00:00
admju
dfa9fe3f1e Gestion des versions 2024-09-12 13:17:49 +00:00
admju
5d4de618dd Param. des variables OCDEPLOY_ 2024-09-12 13:12:17 +00:00
admju
3481bccc22 README 2024-09-12 11:27:47 +00:00
admju
199209d9f1 puml -> oc-doc 2024-09-11 13:52:27 +00:00
admju
330e4e9d4a Suppression fichiers obsolèles 2024-09-11 13:49:13 +00:00
admju
6fef803ae9 format unix 2024-09-11 13:45:09 +00:00
admju
3271246e74 publish : init 2024-09-11 13:44:20 +00:00
admju
80ef56bbc4 Gestion err download 2024-09-11 13:43:29 +00:00
admju
c1134f7403 values overwrite 2024-09-11 13:40:40 +00:00
admju
9561dc5493 overwrite 2024-09-11 13:28:39 +00:00
admju
279f93224f helm : fichiers multiples + variable 2024-09-11 13:13:28 +00:00
119 changed files with 1388 additions and 2193 deletions

2
.gitignore vendored
View File

@@ -1 +1,3 @@
bin bin
*.base64
env

View File

@@ -1,5 +0,0 @@
apiVersion: v2
name: oc-catalog
description: A Helm chart for deploying the oc-catalog application
version: 0.1.0
appVersion: "1.0"

View File

@@ -1,12 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-oc-catalog
spec:
selector:
app: {{ .Chart.Name }}
ports:
- protocol: TCP
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.targetPort }}
type: {{ .Values.service.type }}

View File

@@ -1,33 +0,0 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-oc-catalog
labels:
app: oc-catalog
spec:
serviceName: "{{ .Release.Name }}-oc-catalog"
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: oc-catalog
template:
metadata:
labels:
app: oc-catalog
spec:
containers:
- name: oc-catalog
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: 8080
env:
- name: MONGO_DATABASE
value: "DC_myDC"
- name: MONGO_URI
value: "mongodb://mongo:27017"
imagePullSecrets:
{{- if .Values.imagePullSecrets }}
{{- range .Values.imagePullSecrets }}
- name: {{ .name }}
{{- end }}
{{- end }}

View File

@@ -1,19 +0,0 @@
replicaCount: 1
image:
repository: registry.dev.svc.cluster.local:5000/oc-catalog
tag: latest
pullPolicy: IfNotPresent
service:
type: NodePort
port: 8087
targetPort: 8080
mongo:
database: DC_myDC
uri: mongodb://mongo:27017
imagePullSecrets:
- name: regcred

View File

@@ -1,23 +0,0 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@@ -1,12 +0,0 @@
dependencies:
- name: oc-mongo
repository: file://../oc-mongo
version: 0.1.0
- name: oc-mongo-express
repository: file://../oc-mongo-express
version: 0.1.0
- name: oc-catalog
repository: file://../oc-catalog
version: 0.1.0
digest: sha256:036af8acf7fe0a73f039776d13f63aeb7530e7a8b0febb49fd5e8415ac6672c6
generated: "2024-08-27T14:34:41.6038407+02:00"

View File

@@ -1,14 +0,0 @@
apiVersion: v2
name: oc-deploy
description: A Helm chart to deploy oc-mongo, oc-mongo-express, and oc-catalog together
version: 0.1.0
dependencies:
- name: oc-mongo
version: 0.1.0
repository: "file://../oc-mongo"
- name: oc-mongo-express
version: 0.1.0
repository: "file://../oc-mongo-express"
- name: oc-catalog
version: 0.1.0
repository: "file://../oc-catalog"

View File

@@ -1,5 +0,0 @@
apiVersion: v2
name: oc-catalog
description: A Helm chart for deploying the oc-catalog application
version: 0.1.0
appVersion: "1.0"

View File

@@ -1,12 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: oc-catalog
spec:
selector:
app: {{ .Chart.Name }}
ports:
- protocol: TCP
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.targetPort }}
type: {{ .Values.service.type }}

View File

@@ -1,33 +0,0 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-oc-catalog
labels:
app: oc-catalog
spec:
serviceName: "oc-catalog"
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: oc-catalog
template:
metadata:
labels:
app: oc-catalog
spec:
containers:
- name: oc-catalog
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: 8080
env:
- name: MONGO_DATABASE
value: "DC_myDC"
- name: MONGO_URI
value: "mongodb://{{ .Release.Name }}-mongo:27017"
imagePullSecrets:
{{- if .Values.imagePullSecrets }}
{{- range .Values.imagePullSecrets }}
- name: {{ .name }}
{{- end }}
{{- end }}

View File

@@ -1,19 +0,0 @@
replicaCount: 1
image:
repository: registry.dev.svc.cluster.local:5000/oc-catalog
tag: latest
pullPolicy: IfNotPresent
service:
type: NodePort
port: 8087
targetPort: 8080
mongo:
database: DC_myDC
uri: mongodb://oc-deploy-mongo:27017
imagePullSecrets:
- name: regcred

View File

@@ -1,5 +0,0 @@
apiVersion: v2
name: oc-mongo-express
description: A Helm chart for deploying mongo-express
version: 0.1.0
appVersion: "1.0"

View File

@@ -1,12 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: mongo-express
spec:
selector:
app: mongo-express
ports:
- protocol: TCP
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.targetPort }}
type: {{ .Values.service.type }}

View File

@@ -1,39 +0,0 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-mongo-express
labels:
app: mongo-express
spec:
serviceName: "mongo-express"
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: mongo-express
template:
metadata:
labels:
app: mongo-express
spec:
containers:
- name: mongo-express
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: {{ .Values.service.targetPort }}
env:
- name: ME_CONFIG_BASICAUTH_USERNAME
valueFrom:
secretKeyRef:
name: mongo-secret
key: {{ .Values.secret.usernameKey }}
- name: ME_CONFIG_BASICAUTH_PASSWORD
valueFrom:
secretKeyRef:
name: mongo-secret
key: {{ .Values.secret.passwordKey }}
imagePullSecrets:
{{- if .Values.imagePullSecrets }}
{{- range .Values.imagePullSecrets }}
- name: {{ .name }}
{{- end }}
{{- end }}

View File

@@ -1,18 +0,0 @@
replicaCount: 1
image:
repository: mongo-express
tag: latest
pullPolicy: IfNotPresent
service:
port: 8081
targetPort: 8081
type: NodePort
imagePullSecrets:
- name: my-registry-key
secret:
usernameKey: mongo-username
passwordKey: mongo-password

View File

@@ -1,5 +0,0 @@
apiVersion: v2
name: oc-mongo
description: A Helm chart for deploying the oc-mongo component
version: 0.1.0
appVersion: "1.0"

View File

@@ -1,10 +0,0 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.persistence.name }}
spec:
accessModes:
- {{ .Values.persistence.accessMode }}
resources:
requests:
storage: {{ .Values.persistence.size }}

View File

@@ -1,8 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-mongo-secret
type: Opaque
data:
username: {{ .Values.secret.username }}
password: {{ .Values.secret.password }}

View File

@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: mongo
spec:
selector:
app: mongo
ports:
- protocol: TCP
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}

View File

@@ -1,31 +0,0 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-mongo
labels:
app: mongo
spec:
serviceName: "mongo"
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-persistent-storage
mountPath: /data/db
- name: mongo-persistent-storage
mountPath: /data/configdb
volumes:
- name: mongo-persistent-storage
persistentVolumeClaim:
claimName: {{ .Values.persistence.name }}

View File

@@ -1,19 +0,0 @@
replicaCount: 1
image:
repository: mongo
tag: latest
pullPolicy: IfNotPresent
service:
port: 27017
persistence:
name: mongo-pvc-helm
enabled: true
accessMode: ReadWriteOnce
size: 1Gi
secret:
username: dGVzdA== # base64 encoding of 'test'
password: dGVzdA== # base64 encoding of 'test'

View File

@@ -1,48 +0,0 @@
oc-mongo:
replicaCount: 1
image:
repository: registry.dev.svc.cluster.local:5000/mongo
tag: latest
pullPolicy: IfNotPresent
service:
port: 27017
persistence:
name: mongo-pvc-helm
enabled: true
accessMode: ReadWriteOnce
size: 1Gi
secret:
username: dGVzdA== # base64 encoding of 'test'
password: dGVzdA== # base64 encoding of 'test'
oc-mongo-express:
replicaCount: 1
image:
repository: registry.dev.svc.cluster.local:5000/mongo-express
tag: latest
pullPolicy: IfNotPresent
service:
port: 8081
targetPort: 8081
type: NodePort
imagePullSecrets:
- name: regcred
secret:
usernameKey: mongo-username
passwordKey: mongo-password
oc-catalog:
replicaCount: 1
image:
repository: registry.dev.svc.cluster.local:5000/oc-catalog
tag: latest
pullPolicy: IfNotPresent
service:
type: NodePort
port: 8087
targetPort: 8080
mongo:
database: DC_myDC
uri: mongodb://oc-catalog-mongo:27017
imagePullSecrets:
- name: regcred

View File

@@ -1,5 +0,0 @@
apiVersion: v2
name: oc-mongo-express
description: A Helm chart for deploying mongo-express
version: 0.1.0
appVersion: "1.0"

View File

@@ -1,12 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-mongo-express
spec:
selector:
app: mongo-express
ports:
- protocol: TCP
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.targetPort }}
type: {{ .Values.service.type }}

View File

@@ -1,39 +0,0 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-mongo-express
labels:
app: mongo-express
spec:
serviceName: "{{ .Release.Name }}-mongo-express"
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: mongo-express
template:
metadata:
labels:
app: mongo-express
spec:
containers:
- name: mongo-express
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: {{ .Values.service.targetPort }}
env:
- name: ME_CONFIG_BASICAUTH_USERNAME
valueFrom:
secretKeyRef:
name: mongo-secret
key: {{ .Values.secret.usernameKey }}
- name: ME_CONFIG_BASICAUTH_PASSWORD
valueFrom:
secretKeyRef:
name: mongo-secret
key: {{ .Values.secret.passwordKey }}
imagePullSecrets:
{{- if .Values.imagePullSecrets }}
{{- range .Values.imagePullSecrets }}
- name: {{ .name }}
{{- end }}
{{- end }}

View File

@@ -1,18 +0,0 @@
replicaCount: 1
image:
repository: mongo-express
tag: latest
pullPolicy: IfNotPresent
service:
port: 8081
targetPort: 8081
type: NodePort
imagePullSecrets:
- name: my-registry-key
secret:
usernameKey: mongo-username
passwordKey: mongo-password

View File

@@ -1,5 +0,0 @@
apiVersion: v2
name: oc-mongo
description: A Helm chart for deploying the oc-mongo component
version: 0.1.0
appVersion: "1.0"

View File

@@ -1,10 +0,0 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Values.persistence.name }}
spec:
accessModes:
- {{ .Values.persistence.accessMode }}
resources:
requests:
storage: {{ .Values.persistence.size }}

View File

@@ -1,8 +0,0 @@
apiVersion: v1
kind: Secret
metadata:
name: {{ .Release.Name }}-mongo-secret
type: Opaque
data:
username: {{ .Values.secret.username }}
password: {{ .Values.secret.password }}

View File

@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: mongo
spec:
selector:
app: mongo
ports:
- protocol: TCP
port: {{ .Values.service.port }}
targetPort: {{ .Values.service.port }}

View File

@@ -1,31 +0,0 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-mongo
labels:
app: mongo
spec:
serviceName: "{{ .Release.Name }}-mongo"
replicas: {{ .Values.replicaCount }}
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-persistent-storage
mountPath: /data/db
- name: mongo-persistent-storage
mountPath: /data/configdb
volumes:
- name: mongo-persistent-storage
persistentVolumeClaim:
claimName: {{ .Values.persistence.name }}

View File

@@ -1,19 +0,0 @@
replicaCount: 1
image:
repository: mongo
tag: latest
pullPolicy: IfNotPresent
service:
port: 27017
persistence:
name: mongo-pvc-helm
enabled: true
accessMode: ReadWriteOnce
size: 1Gi
secret:
username: dGVzdA== # base64 encoding of 'test'
password: dGVzdA== # base64 encoding of 'test'

34
Makefile Normal file
View File

@@ -0,0 +1,34 @@
#!make
include env
export
ifndef OC_VERSION
$(error OC_VERSION is not set)
endif
ifndef PUBLISH_TOKEN
$(error PUBLISH_TOKEN is not set)
endif
PUBLISH_REPO := "core/oc-deploy"
PUBLISH_BRANCH := main
help:
@echo
@echo 'Usage:'
@echo ' make publish'
@echo ' make clean'
.PHONY: publish
publish:
@echo Publication de : ${OC_VERSION}
@(cd src && make --quiet build VERSION=$(OC_VERSION))
@(cd publish && \
PUBLISH_REPO=${PUBLISH_REPO} \
PUBLISH_TOKEN=${PUBLISH_TOKEN} \
PUBLISH_BRANCH=${PUBLISH_BRANCH} \
go run main.go ${OC_VERSION})
clean:
@rm *.base64

110
README.md
View File

@@ -4,36 +4,114 @@ The purpose of oc-deploy, is to deploy all the OC components over a Kubernetes c
An OpenCloud deployment is composed of the following layers: An OpenCloud deployment is composed of the following layers:
OpenCloud components | <-- TODO
-------------------------- | Layer | Tool |
KubernetesCluster | <-- TODO | ------------------------ | --------------------- |
-------------------------- | OpenCloud components | oc-deploy binary |
IaaS (VMs, LAN) | <-- pre-requisite | KubernetesCluster | TODO or pre-requisite |
-------------------------- | IaaS (VMs, LAN) | pre-requisite |
HW (network and servers) | <-- pre-requisite | HW (network and servers) | <-- pre-requisite |
--------------------------
It thus contains a first optional installation layer which deploys the Kubernetes nodes (control plane(s) and workers) above an existing infrastructure (Iaas). It thus contains a first optional installation layer which deploys the Kubernetes nodes (control plane(s) and workers) above an existing infrastructure (Iaas).
Then the second installation layer uses Helm charts to deploy and configure all the OC components.
This documentation will be updated with the needed command and/or requirements to properly execute the installation. This documentation will be updated with the needed command and/or requirements to properly execute the installation.
# Deploy cluster
## For dev in Docker # oc-deploy tools
Install brew
## Usage
| Command | Description |
| ----------------------------------------------------------------------------- | --------------------------- |
| ```oc-deploy``` | Display help |
| ```oc-deploy version``` | Display the version of tool |
| ```oc-deploy install [-c\|--context <context>] [-v\|--version <OcVersion>]``` | Deploy an OpenCloud |
| ```oc-deploy uninstall [-c\|--context <context>]``` | Undeploy an OpenCloud |
| Arguments | Description | Default |
| ---------------- | --------------------------- | ------------ |
| ```context``` | Context Kubernetes | _opencloud_ |
| ```OcVersion``` | Specific version or latest | _latest_ |
## Principe
* Download an "OpenCloud file version" : oc_<version>.yml from relase on GitEa (core/oc-version).
* Initialise an workspace direcotry : ./workspace_<contextK8S>
* Install tools as describe, if not found on the path :
* Helm
* Kubectl
* Check if the Cluster (context) is available
* Install all charts as describe :
* Charts : from Harbor or local
* Images : from Harbor or local
* Check if componants are available
## Pre-requis
**oc-deploy** need to access to an Kubernetes Cluster, c'est-à-dire : kubeconfig.
**oc-deploy** need to access to Internet :
* to download the _oc.json_ file (contient _oc.yml_) :
* Url : https://cloud.o-forge.io/core/oc-deploy/releases
* to download _kubectl_ and _helm_ tools if
* Url : Urls are specified into _oc.yml_
## Dev
Cf. src/README.md
## Publish
Publish in the relase GitEa the binary (the binary is base64 coding).
Set **env** file to overwrite varibable as :
#!make
PUBLISH_TOKEN = <gitea_token>
To publish :
OC_VERSION = <x.y.z> make publish
# Installation on Kubernetes
## Minikube
TO DO
## Kubernetes
TO DO
## RKE2
TO DO
## OpenShift
TO DO
# Installation on Docker
Without Kubernetes, for dev in Docker
## Install brew
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)" /bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)"
Install Talos ## Install Talos
brew install siderolabs/tap/talosctl brew install siderolabs/tap/talosctl
talosctl cluster create talosctl cluster create
# Install helm ## Install helm
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh chmod 700 get_helm.sh
./get_helm.sh ./get_helm.sh
# Create OpenCloud Chart ## Create OpenCloud Chart
Obsolete : use oc-deploy tool
helm create occhart helm create occhart

View File

@@ -1,53 +0,0 @@
@startuml
top to bottom direction
component front as "oc-front" #MistyRose
component api as "oc-api" #BlueViolet
component auth as "oc-auth" #BlueViolet
component catalog as "oc-catalog" #MistyRose
component workspace as "oc-workspace" #MistyRose
component workflow as "oc-workflow" #MistyRose
component calendarIn as "oc-calendar-in" #MistyRose
component calendarOut as "oc-calendar-out" #MistyRose
component stat as "oc-status" #MistyRose
component disco as "oc-discovery" #MistyRose
component agg as "oc-aggregator" #MistyRose
component scheduler as "oc-scheduler" #LightYellow
component monitor as "oc-monitor" #LightYellow
database rd as "Nats" #Green
database zn as "Zinc" #Green
database loki as "Loki" #Green
database mongo as "MongoDB" #Green
database nats as "Nats" #Green
front -- api
api -- auth : auth user
api -- catalog : local search
api -- workspace : store user data
api -- workflow
api -- calendarIn
api -- calendarOut
api -- stat
catalog -- disco
catalog -- agg
scheduler -- monitor
scheduler -- catalog
rd -- scheduler
loki -- monitor
catalog -- mongo : store resources available for users
workspace -- mongo : store resources allocated to a workspace
workflow -- mongo : store workflow
calendarOut -- mongo : store booking informations for this dc
@enduml

View File

@@ -1,88 +0,0 @@
version: '3.8'
services:
traefik:
image: traefik:latest
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--entrypoints.web.address=:80"
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
mongo:
image: mongo:latest
ports:
- "27017:27017"
volumes:
- mongo-data:/data/db
labels:
- "traefik.enable=true"
- "traefik.http.routers.mongo.rule=PathPrefix(`/mongo`)"
- "traefik.http.services.mongo.loadbalancer.server.port=27017"
nats:
image: nats:latest
ports:
- "4222:4222"
labels:
- "traefik.enable=true"
- "traefik.http.routers.nats.rule=PathPrefix(`/nats`)"
- "traefik.http.services.nats.loadbalancer.server.port=4222"
zinc:
image: public.ecr.aws/zinclabs/zincsearch:latest
ports:
- "4080:4080"
labels:
- "traefik.enable=true"
- "traefik.http.routers.zinc.rule=PathPrefix(`/zinc`)"
- "traefik.http.services.zinc.loadbalancer.server.port=4080"
dex:
image: quay.io/dexidp/dex:latest
ports:
- "5556:5556"
volumes:
- ./dex/config.yaml:/etc/dex/cfg/config.yaml
command: ["dex", "serve", "/etc/dex/cfg/config.yaml"]
labels:
- "traefik.enable=true"
- "traefik.http.routers.dex.rule=PathPrefix(`/dex`)"
- "traefik.http.services.dex.loadbalancer.server.port=5556"
ldap:
image: bitnami/openldap
ports:
- "389:389"
environment:
- LDAP_ADMIN_USERNAME=admin
- LDAP_ADMIN_PASSWORD=adminpassword
- LDAP_USERS=user01,user02
- LDAP_PASSWORDS=password1,password2
grafana:
image: grafana/grafana:latest
ports:
- "3000:3000"
environment:
GF_SECURITY_ADMIN_PASSWORD: "admin"
labels:
- "traefik.enable=true"
- "traefik.http.routers.grafana.rule=PathPrefix(`/grafana`)"
- "traefik.http.services.grafana.loadbalancer.server.port=3000"
loki:
image: grafana/loki:latest
ports:
- "3100:3100"
labels:
- "traefik.enable=true"
- "traefik.http.routers.loki.rule=PathPrefix(`/loki`)"
- "traefik.http.services.loki.loadbalancer.server.port=3100"
volumes:
mongo-data:

View File

@@ -1,23 +0,0 @@
# Patterns to ignore when building packages.
# This supports shell glob matching, relative path matching, and
# negation (prefixed with !). Only one pattern per line.
.DS_Store
# Common VCS dirs
.git/
.gitignore
.bzr/
.bzrignore
.hg/
.hgignore
.svn/
# Common backup files
*.swp
*.bak
*.tmp
*.orig
*~
# Various IDEs
.project
.idea/
*.tmproj
.vscode/

View File

@@ -1,24 +0,0 @@
apiVersion: v2
name: occhart
description: A Helm chart for Kubernetes
# A chart can be either an 'application' or a 'library' chart.
#
# Application charts are a collection of templates that can be packaged into versioned archives
# to be deployed.
#
# Library charts provide useful utilities or functions for the chart developer. They're included as
# a dependency of application charts to inject those utilities and functions into the rendering
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.1.0
# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
# follow Semantic Versioning. They should reflect the version the application is using.
# It is recommended to use it with quotes.
appVersion: "1.16.0"

View File

@@ -1,32 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: dex
labels:
app: dex
spec:
replicas: 1
selector:
matchLabels:
app: dex
template:
metadata:
labels:
app: dex
spec:
containers:
- name: dex
image: quay.io/dexidp/dex:v2.27.0
ports:
- containerPort: 5556
args:
- serve
- /etc/dex/cfg/config.yaml
volumeMounts:
- mountPath: /etc/dex/cfg
name: config
volumes:
- name: config
configMap:
name: dex-config

View File

@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: dex
labels:
app: dex
spec:
ports:
- port: 5556
selector:
app: dex

View File

@@ -1,21 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: grafana
labels:
app: grafana
spec:
replicas: 1
selector:
matchLabels:
app: grafana
template:
metadata:
labels:
app: grafana
spec:
containers:
- name: grafana
image: grafana/grafana:7.5.0
ports:
- containerPort: 3000

View File

@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: grafana
labels:
app: grafana
spec:
ports:
- port: 3000
selector:
app: grafana

View File

@@ -1,21 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: ldap
labels:
app: ldap
spec:
replicas: 1
selector:
matchLabels:
app: ldap
template:
metadata:
labels:
app: ldap
spec:
containers:
- name: ldap
image: osixia/openldap:1.5.0
ports:
- containerPort: 389

View File

@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: ldap
labels:
app: ldap
spec:
ports:
- port: 389
selector:
app: ldap

View File

@@ -1,21 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: loki
labels:
app: loki
spec:
replicas: 1
selector:
matchLabels:
app: loki
template:
metadata:
labels:
app: loki
spec:
containers:
- name: loki
image: grafana/loki:2.2.0
ports:
- containerPort: 3100

View File

@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: loki
labels:
app: loki
spec:
ports:
- port: 3100
selector:
app: loki

View File

@@ -1,21 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo
labels:
app: mongo
spec:
replicas: 1
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: mongo:4.4
ports:
- containerPort: 27017

View File

@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: mongo
labels:
app: mongo
spec:
ports:
- port: 27017
selector:
app: mongo

View File

@@ -1,21 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: nats
labels:
app: nats
spec:
replicas: 1
selector:
matchLabels:
app: nats
template:
metadata:
labels:
app: nats
spec:
containers:
- name: nats
image: nats:2.1.9
ports:
- containerPort: 4222

View File

@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: nats
labels:
app: nats
spec:
ports:
- port: 4222
selector:
app: nats

View File

@@ -1,37 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: traefik
labels:
app: traefik
spec:
replicas: 1
selector:
matchLabels:
app: traefik
template:
metadata:
labels:
app: traefik
spec:
containers:
- name: traefik
image: traefik:v2.4
ports:
- name: web
containerPort: 80
- name: admin
containerPort: 8080
args:
- --entrypoints.web.address=:80
- --entrypoints.websecure.address=:443
- --providers.kubernetescrd
- --api
volumeMounts:
- mountPath: /etc/traefik
name: traefik-config
volumes:
- name: traefik-config
configMap:
name: traefik-config

View File

@@ -1,81 +0,0 @@
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: traefik-ingress
annotations:
traefik.ingress.kubernetes.io/router.entrypoints: web
spec:
rules:
- host: <your-domain>
http:
paths:
- path: /front
pathType: Prefix
backend:
service:
name: front-service
port:
number: 80
- path: /back1
pathType: Prefix
backend:
service:
name: back1-service
port:
number: 80
- path: /back2
pathType: Prefix
backend:
service:
name: back2-service
port:
number: 80
- path: /mongo
pathType: Prefix
backend:
service:
name: mongo
port:
number: 27017
- path: /nats
pathType: Prefix
backend:
service:
name: nats
port:
number: 4222
- path: /zinc
pathType: Prefix
backend:
service:
name: zinc
port:
number: 4080
- path: /dex
pathType: Prefix
backend:
service:
name: dex
port:
number: 5556
- path: /ldap
pathType: Prefix
backend:
service:
name: ldap
port:
number: 389
- path: /grafana
pathType: Prefix
backend:
service:
name: grafana
port:
number: 3000
- path: /loki
pathType: Prefix
backend:
service:
name: loki
port:
number: 3100

View File

@@ -1,17 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: traefik
labels:
app: traefik
spec:
type: LoadBalancer
ports:
- port: 80
name: web
targetPort: 80
- port: 8080
name: admin
targetPort: 8080
selector:
app: traefik

View File

@@ -1,21 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: zinc
labels:
app: zinc
spec:
replicas: 1
selector:
matchLabels:
app: zinc
template:
metadata:
labels:
app: zinc
spec:
containers:
- name: zinc
image: public.ecr.aws/zinclabs/zinc:latest
ports:
- containerPort: 4080

View File

@@ -1,11 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: zinc
labels:
app: zinc
spec:
ports:
- port: 4080
selector:
app: zinc

View File

@@ -1,22 +0,0 @@
1. Get the application URL by running these commands:
{{- if .Values.ingress.enabled }}
{{- range $host := .Values.ingress.hosts }}
{{- range .paths }}
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
{{- end }}
{{- end }}
{{- else if contains "NodePort" .Values.service.type }}
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "occhart.fullname" . }})
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
echo http://$NODE_IP:$NODE_PORT
{{- else if contains "LoadBalancer" .Values.service.type }}
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
You can watch its status by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "occhart.fullname" . }}'
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "occhart.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
echo http://$SERVICE_IP:{{ .Values.service.port }}
{{- else if contains "ClusterIP" .Values.service.type }}
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "occhart.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
echo "Visit http://127.0.0.1:8080 to use your application"
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
{{- end }}

View File

@@ -1,62 +0,0 @@
{{/*
Expand the name of the chart.
*/}}
{{- define "occhart.name" -}}
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Create a default fully qualified app name.
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
If release name contains chart name it will be used as a full name.
*/}}
{{- define "occhart.fullname" -}}
{{- if .Values.fullnameOverride }}
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- $name := default .Chart.Name .Values.nameOverride }}
{{- if contains $name .Release.Name }}
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
{{- else }}
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
{{- end }}
{{- end }}
{{- end }}
{{/*
Create chart name and version as used by the chart label.
*/}}
{{- define "occhart.chart" -}}
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
{{- end }}
{{/*
Common labels
*/}}
{{- define "occhart.labels" -}}
helm.sh/chart: {{ include "occhart.chart" . }}
{{ include "occhart.selectorLabels" . }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}
{{/*
Selector labels
*/}}
{{- define "occhart.selectorLabels" -}}
app.kubernetes.io/name: {{ include "occhart.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- end }}
{{/*
Create the name of the service account to use
*/}}
{{- define "occhart.serviceAccountName" -}}
{{- if .Values.serviceAccount.create }}
{{- default (include "occhart.fullname" .) .Values.serviceAccount.name }}
{{- else }}
{{- default "default" .Values.serviceAccount.name }}
{{- end }}
{{- end }}

View File

@@ -1,68 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "occhart.fullname" . }}
labels:
{{- include "occhart.labels" . | nindent 4 }}
spec:
{{- if not .Values.autoscaling.enabled }}
replicas: {{ .Values.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "occhart.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "occhart.labels" . | nindent 8 }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
spec:
{{- with .Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "occhart.serviceAccountName" . }}
securityContext:
{{- toYaml .Values.podSecurityContext | nindent 8 }}
containers:
- name: {{ .Chart.Name }}
securityContext:
{{- toYaml .Values.securityContext | nindent 12 }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
- name: http
containerPort: {{ .Values.service.port }}
protocol: TCP
livenessProbe:
{{- toYaml .Values.livenessProbe | nindent 12 }}
readinessProbe:
{{- toYaml .Values.readinessProbe | nindent 12 }}
resources:
{{- toYaml .Values.resources | nindent 12 }}
{{- with .Values.volumeMounts }}
volumeMounts:
{{- toYaml . | nindent 12 }}
{{- end }}
{{- with .Values.volumes }}
volumes:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}

View File

@@ -1,32 +0,0 @@
{{- if .Values.autoscaling.enabled }}
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: {{ include "occhart.fullname" . }}
labels:
{{- include "occhart.labels" . | nindent 4 }}
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: {{ include "occhart.fullname" . }}
minReplicas: {{ .Values.autoscaling.minReplicas }}
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
metrics:
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
{{- end }}
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
{{- end }}
{{- end }}

View File

@@ -1,61 +0,0 @@
{{- if .Values.ingress.enabled -}}
{{- $fullName := include "occhart.fullname" . -}}
{{- $svcPort := .Values.service.port -}}
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
{{- end }}
{{- end }}
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
apiVersion: networking.k8s.io/v1beta1
{{- else -}}
apiVersion: extensions/v1beta1
{{- end }}
kind: Ingress
metadata:
name: {{ $fullName }}
labels:
{{- include "occhart.labels" . | nindent 4 }}
{{- with .Values.ingress.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
ingressClassName: {{ .Values.ingress.className }}
{{- end }}
{{- if .Values.ingress.tls }}
tls:
{{- range .Values.ingress.tls }}
- hosts:
{{- range .hosts }}
- {{ . | quote }}
{{- end }}
secretName: {{ .secretName }}
{{- end }}
{{- end }}
rules:
{{- range .Values.ingress.hosts }}
- host: {{ .host | quote }}
http:
paths:
{{- range .paths }}
- path: {{ .path }}
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
pathType: {{ .pathType }}
{{- end }}
backend:
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
service:
name: {{ $fullName }}
port:
number: {{ $svcPort }}
{{- else }}
serviceName: {{ $fullName }}
servicePort: {{ $svcPort }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}

View File

@@ -1,15 +0,0 @@
apiVersion: v1
kind: Service
metadata:
name: {{ include "occhart.fullname" . }}
labels:
{{- include "occhart.labels" . | nindent 4 }}
spec:
type: {{ .Values.service.type }}
ports:
- port: {{ .Values.service.port }}
targetPort: http
protocol: TCP
name: http
selector:
{{- include "occhart.selectorLabels" . | nindent 4 }}

View File

@@ -1,13 +0,0 @@
{{- if .Values.serviceAccount.create -}}
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ include "occhart.serviceAccountName" . }}
labels:
{{- include "occhart.labels" . | nindent 4 }}
{{- with .Values.serviceAccount.annotations }}
annotations:
{{- toYaml . | nindent 4 }}
{{- end }}
automountServiceAccountToken: {{ .Values.serviceAccount.automount }}
{{- end }}

View File

@@ -1,15 +0,0 @@
apiVersion: v1
kind: Pod
metadata:
name: "{{ include "occhart.fullname" . }}-test-connection"
labels:
{{- include "occhart.labels" . | nindent 4 }}
annotations:
"helm.sh/hook": test
spec:
containers:
- name: wget
image: busybox
command: ['wget']
args: ['{{ include "occhart.fullname" . }}:{{ .Values.service.port }}']
restartPolicy: Never

View File

@@ -1,107 +0,0 @@
# Default values for occhart.
# This is a YAML-formatted file.
# Declare variables to be passed into your templates.
replicaCount: 1
image:
repository: nginx
pullPolicy: IfNotPresent
# Overrides the image tag whose default is the chart appVersion.
tag: ""
imagePullSecrets: []
nameOverride: ""
fullnameOverride: ""
serviceAccount:
# Specifies whether a service account should be created
create: true
# Automatically mount a ServiceAccount's API credentials?
automount: true
# Annotations to add to the service account
annotations: {}
# The name of the service account to use.
# If not set and create is true, a name is generated using the fullname template
name: ""
podAnnotations: {}
podLabels: {}
podSecurityContext: {}
# fsGroup: 2000
securityContext: {}
# capabilities:
# drop:
# - ALL
# readOnlyRootFilesystem: true
# runAsNonRoot: true
# runAsUser: 1000
service:
type: ClusterIP
port: 80
ingress:
enabled: false
className: ""
annotations: {}
# kubernetes.io/ingress.class: nginx
# kubernetes.io/tls-acme: "true"
hosts:
- host: chart-example.local
paths:
- path: /
pathType: ImplementationSpecific
tls: []
# - secretName: chart-example-tls
# hosts:
# - chart-example.local
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
# limits:
# cpu: 100m
# memory: 128Mi
# requests:
# cpu: 100m
# memory: 128Mi
livenessProbe:
httpGet:
path: /
port: http
readinessProbe:
httpGet:
path: /
port: http
autoscaling:
enabled: false
minReplicas: 1
maxReplicas: 100
targetCPUUtilizationPercentage: 80
# targetMemoryUtilizationPercentage: 80
# Additional volumes on the output Deployment definition.
volumes: []
# - name: foo
# secret:
# secretName: mysecret
# optional: false
# Additional volumeMounts on the output Deployment definition.
volumeMounts: []
# - name: foo
# mountPath: "/etc/foo"
# readOnly: true
nodeSelector: {}
tolerations: []
affinity: {}

View File

@@ -1,29 +0,0 @@
# oc-catalog-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: oc-catalog
labels:
app: oc-catalog
spec:
replicas: 1
selector:
matchLabels:
app: oc-catalog
template:
metadata:
labels:
app: oc-catalog
spec:
containers:
- name: oc-catalog
image: registry.dev.svc.cluster.local:5000/oc-catalog:latest
ports:
- containerPort: 8080
env:
- name: MONGO_DATABASE
value: "DC_myDC"
- name: MONGO_URI
value: "mongodb://mongo:27017"
imagePullSecrets:
- name: regcred

View File

@@ -1,13 +0,0 @@
# oc-catalog-service.yml
apiVersion: v1
kind: Service
metadata:
name: oc-catalog
spec:
selector:
app: oc-catalog
ports:
- protocol: TCP
port: 8087
targetPort: 8080
type: NodePort # Optional, useful for accessing via Minikube IP and NodePort

View File

@@ -1,32 +0,0 @@
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo-express
spec:
replicas: 1
selector:
matchLabels:
app: mongo-express
template:
metadata:
labels:
app: mongo-express
spec:
containers:
- name: mongo-express
image: mongo-express:latest
ports:
- containerPort: 8081
env:
- name: ME_CONFIG_BASICAUTH_USERNAME
valueFrom:
secretKeyRef:
name: mongo-secret
key: mongo-username
- name: ME_CONFIG_BASICAUTH_PASSWORD
valueFrom:
secretKeyRef:
name: mongo-secret
key: mongo-password
imagePullSecrets:
- name: my-registry-key

View File

@@ -1,13 +0,0 @@
# mongo-express-service.yml
apiVersion: v1
kind: Service
metadata:
name: mongo-express
spec:
selector:
app: mongo-express
ports:
- protocol: TCP
port: 8081
targetPort: 8081
type: NodePort # Optional, useful for accessing via Minikube IP and NodePort

View File

@@ -1,42 +0,0 @@
# mongo-deployment.yml
apiVersion: apps/v1
kind: Deployment
metadata:
name: mongo
labels:
app: mongo
spec:
replicas: 1
selector:
matchLabels:
app: mongo
template:
metadata:
labels:
app: mongo
spec:
containers:
- name: mongo
image: mongo:latest
ports:
- containerPort: 27017
volumeMounts:
- name: mongo-persistent-storage
mountPath: /data/db
- name: mongo-persistent-storage
mountPath: /data/configdb
volumes:
- name: mongo-persistent-storage
persistentVolumeClaim:
claimName: mongo-pvc
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: mongo-pvc
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi

View File

@@ -1,9 +0,0 @@
# mongo-secret.yml
apiVersion: v1
kind: Secret
metadata:
name: mongo-secret
type: Opaque
data:
username: dGVzdA== # base64 encoding of 'test'
password: dGVzdA== # base64 encoding of 'test'

View File

@@ -1,12 +0,0 @@
# mongo-service.yml
apiVersion: v1
kind: Service
metadata:
name: mongo
spec:
selector:
app: mongo
ports:
- protocol: TCP
port: 27017
targetPort: 27017

View File

@@ -1,7 +0,0 @@
---
globals:
composant1:
composant2:

View File

@@ -1,3 +1,3 @@
--- ---
version: 1.0 version: 0.1.0

View File

@@ -6,10 +6,10 @@ version: 1.0
tools: tools:
- name: kubectl - name: kubectl
url: https://dl.k8s.io/release/%s/bin/linux/amd64/kubectl url: https://dl.k8s.io/release/%s/bin/linux/amd64/kubectl
version: v1.30.3 version: v1.31.0
- name: helm - name: helm
url: https://get.helm.sh/helm-%s-linux-amd64.tar.gz url: https://get.helm.sh/helm-%s-linux-amd64.tar.gz
version: v3.15.4 version: v3.16.0
# helm install my-release <repo>/<chart> # helm install my-release <repo>/<chart>
opencloud: opencloud:

3
publish/.gitignore vendored Normal file
View File

@@ -0,0 +1,3 @@
go.sum
*_
.coverage.*

3
publish/go.mod Normal file
View File

@@ -0,0 +1,3 @@
module oc-publish
go 1.22.2

83
publish/main.go Normal file
View File

@@ -0,0 +1,83 @@
package main
import (
"fmt"
"os"
"io/ioutil"
"encoding/base64"
"oc-publish/releases"
"oc-publish/occonst"
)
func main() {
version := os.Args[1]
fmt.Printf(" >> oc-publish :\n")
fmt.Printf(" << Url : %s/%s\n", occonst.PUBLISH_URL, occonst.PUBLISH_REPO)
fmt.Printf(" << version : %s %s\n", version, occonst.PUBLISH_BRANCH)
vversion := fmt.Sprintf("v%s", version)
existe, _ := releases.CheckRelease(vversion)
if existe == false {
err := releases.CreateRelease(vversion, occonst.PUBLISH_BRANCH)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
idRelease, _ := releases.GetReleaseId(vversion)
if existe == true {
fmt.Println(fmt.Sprintf(" << Release existante : %d ", idRelease))
} else {
fmt.Println(fmt.Sprintf(" << Release crée : %d ", idRelease))
}
assetname := "oc-deploy.base64"
binary := fmt.Sprintf("../bin/oc-deploy")
binary64 := fmt.Sprintf("../%s", assetname)
err := createBinaryFile(binary, binary64)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
idAsset, _ := releases.GetAssetId(idRelease, assetname)
if idAsset == 0 {
fmt.Println(fmt.Sprintf(" << Ajout Asset : %s", assetname))
err := releases.CreateAsset(idRelease, binary64, assetname)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
} else {
fmt.Println(fmt.Sprintf(" << Mise à jour : %s (idAsset=%d) ", assetname, idAsset))
err := releases.UpdateAsset(idRelease, idAsset, binary64, assetname)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
}
}
func createBinaryFile(source string, dest string) error {
fout, _ := os.Create(dest)
defer fout.Close()
byteValue, err := ioutil.ReadFile(source)
if err != nil {
fmt.Println("64e", err)
return err
}
data64 := base64.StdEncoding.EncodeToString(byteValue)
fout.Write([]byte(data64))
return nil
}

View File

@@ -0,0 +1,18 @@
package occonst
import (
"os"
)
var PUBLISH_URL = getenv("PUBLISH_URL", "https://cloud.o-forge.io")
var PUBLISH_REPO = getenv("PUBLISH_REPO", "core/oc-deploy")
var PUBLISH_TOKEN = getenv("PUBLISH_TOKEN", "")
var PUBLISH_BRANCH = getenv("PUBLISH_BRANCH", "main")
func getenv(key string, defaut string) string {
value := os.Getenv(key)
if len(value) == 0 {
return defaut
}
return value
}

6
publish/release.txt Normal file
View File

@@ -0,0 +1,6 @@
Version %s d'OpenCloud
```
wget %s/%s/releases/download/%s/oc-deploy.base64 -O - | base64 -d > oc-deploy
chmod u+x ./oc-deploy
```

145
publish/releases/assets.go Normal file
View File

@@ -0,0 +1,145 @@
package releases
import (
"fmt"
"os"
"path/filepath"
"mime/multipart"
"io"
"io/ioutil"
"encoding/json"
"net/http"
"bytes"
"oc-publish/occonst"
)
type assetStruct struct {
Name string `json:"name"`
Id int `json:"id"`
}
func GetAssetId(idRelease int, name string) (int, error) {
url := fmt.Sprintf("%s/api/v1/repos/%s/releases/%d/assets",
occonst.PUBLISH_URL,
occonst.PUBLISH_REPO,
idRelease)
res, err := http.Get(url)
if err != nil {
return -1, err
}
body, err := io.ReadAll(res.Body)
if err != nil {
return -2, err
}
var data []assetStruct
err = json.Unmarshal(body, &data)
if err != nil {
return -3, err
}
for _, ele := range data {
if ele.Name == name {
return ele.Id, nil
}
}
return 0, nil
}
// curl -X 'POST' \
// 'https://cloud.o-forge.io/api/v1/repos/core/oc-deploy/releases/2/assets?name=zzzz' \
// -H 'accept: application/json' \
// -H 'Content-Type: multipart/form-data' \
// -F 'attachment=oc-deploy'
func CreateAsset(idRelease int, filename string, name string) (error) {
url := fmt.Sprintf("%s/api/v1/repos/%s/releases/%d/assets?name=%s&token=%s",
occonst.PUBLISH_URL,
occonst.PUBLISH_REPO,
idRelease,
name,
occonst.PUBLISH_TOKEN)
err := uploadFile(url, "attachment", filename)
return err
}
func UpdateAsset(idRelease int, idAsset int, filename string, name string) (error) {
url := fmt.Sprintf("%s/api/v1/repos/%s/releases/%d/assets/%d?token=%s",
occonst.PUBLISH_URL,
occonst.PUBLISH_REPO,
idRelease,
idAsset,
occonst.PUBLISH_TOKEN)
// Create client
client := &http.Client{}
// Create request
req, err := http.NewRequest("DELETE", url, nil)
if err != nil {
return err
}
// Fetch Request
resp, err := client.Do(req)
if err != nil {
return err
}
defer resp.Body.Close()
// Read Response Body
respBody, err := ioutil.ReadAll(resp.Body)
if err != nil {
return err
}
fmt.Println(string(respBody))
return CreateAsset(idRelease, filename, name)
}
func uploadFile(url string, paramName string, filePath string) error {
file, err := os.Open(filePath)
if err != nil {
return err
}
defer file.Close()
body := &bytes.Buffer{}
writer := multipart.NewWriter(body)
part, err := writer.CreateFormFile(paramName, filepath.Base(filePath))
if err != nil {
return err
}
_, err = io.Copy(part, file)
err = writer.Close()
if err != nil {
return err
}
request, err := http.NewRequest("POST", url, body)
request.Header.Add("Content-Type", writer.FormDataContentType())
request.Header.Add("accept", "application/json")
client := &http.Client{}
response, err := client.Do(request)
if err != nil {
fmt.Println(109, err)
return err
}
defer response.Body.Close()
if response.StatusCode > 400 {
return fmt.Errorf(response.Status)
}
_, err1 := io.ReadAll(response.Body)
// Handle the server response...
return err1
}

126
publish/releases/release.go Normal file
View File

@@ -0,0 +1,126 @@
package releases
import (
"fmt"
"io"
"io/ioutil"
"strings"
"encoding/json"
"net/http"
"oc-publish/occonst"
)
type checkStruct struct {
Name string `json:"name"`
Id int `json:"id"`
}
func CheckRelease(version string) (bool, error) {
url := fmt.Sprintf("%s/api/v1/repos/%s/releases",
occonst.PUBLISH_URL,
occonst.PUBLISH_REPO)
res, err := http.Get(url)
if err != nil {
return false, err
}
body, err := io.ReadAll(res.Body)
if err != nil {
return false, err
}
var data []checkStruct
err = json.Unmarshal(body, &data)
if err != nil {
return false, err
}
for _, ele := range data {
if ele.Name == version {
return true, nil
}
}
// return data.Name != "", nil
return false, nil
}
func GetReleaseId(version string) (int, error) {
url := fmt.Sprintf("%s/api/v1/repos/%s/releases/tags/%s",
occonst.PUBLISH_URL,
occonst.PUBLISH_REPO,
version)
res, err := http.Get(url)
if err != nil {
return 0, err
}
body, err := io.ReadAll(res.Body)
if err != nil {
return 0, err
}
var data checkStruct
err = json.Unmarshal(body, &data)
if err != nil {
return 0, err
}
return data.Id, nil
}
// curl -X 'POST' \
// 'https://cloud.o-forge.io/api/v1/repos/na/oc-version/releases?token=sss' \
// -H 'accept: application/json' \
// -H 'Content-Type: application/json' \
// -d '{
// "body": "string",
// "draft": true,
// "name": "string",
// "prerelease": true,
// "tag_name": "string",
// "target_commitish": "string"
// }'
func CreateRelease(version string, branch string) (error) {
url := fmt.Sprintf("%s/api/v1/repos/%s/releases?token=%s",
occonst.PUBLISH_URL,
occonst.PUBLISH_REPO,
occonst.PUBLISH_TOKEN)
releasebytes, err := ioutil.ReadFile("release.txt")
releasetxt := string(releasebytes)
releasetxt = strings.Replace(releasetxt, "\n", "\\n", -1)
releasetxt = fmt.Sprintf(releasetxt, version, occonst.PUBLISH_URL, occonst.PUBLISH_REPO, version)
body := fmt.Sprintf(`{
"body": "%s",
"draft": false,
"name": "%s",
"prerelease": false,
"tag_name": "%s",
"target_commitish": "%s"
}`, releasetxt, version, version, branch)
request, err := http.NewRequest("POST", url, strings.NewReader(body))
if err != nil {
return err
}
request.Header.Add("accept", "application/json")
request.Header.Add("Content-Type", "application/json")
client := &http.Client{}
response, err := client.Do(request)
if err != nil {
return err
}
defer response.Body.Close()
_, err1 := io.ReadAll(response.Body)
// cnt, err1 := io.ReadAll(response.Body)
// fmt.Println(string(cnt))
if err1 != nil {
return err1
}
return nil
}

View File

@@ -11,6 +11,16 @@ BIN_DIR = ../bin/
PLUGINS := $(wildcard ../plugins/*/*.go) PLUGINS := $(wildcard ../plugins/*/*.go)
OBJS := ${PLUGINS:.go=.so} OBJS := ${PLUGINS:.go=.so}
##################
DATE := $(shell date --iso-8601)
GOVERSION := $(shell go version)
VERSION := $(shell git describe --tags --abbrev=8 --dirty --always --long)
PREFIX := oc-deploy/occonst
LDFLAGS := "-X '${PREFIX}.Version=${VERSION}' -X '${PREFIX}.Date=${DATE}' -X '${PREFIX}.GoVersion=${GOVERSION}'"
##################
%.so: %.go %.so: %.go
go build -buildmode=plugin -o $@ $< go build -buildmode=plugin -o $@ $<
@@ -23,35 +33,44 @@ help:
@echo ' make run BIN_OPTS=... Go run' @echo ' make run BIN_OPTS=... Go run'
@echo ' make run_install BIN_OPTS=... Go run' @echo ' make run_install BIN_OPTS=... Go run'
@echo ' make run_uninstall BIN_OPTS=... Go run' @echo ' make run_uninstall BIN_OPTS=... Go run'
@echo ' make run_version Go run'
@echo ' make exec BIN_OPTS=... exécutable' @echo ' make exec BIN_OPTS=... exécutable'
@echo ' make exec_install BIN_OPTS=... exécutable' @echo ' make exec_install BIN_OPTS=... exécutable'
@echo ' make exec_uninstall BIN_OPTS=... exécutable' @echo ' make exec_uninstall BIN_OPTS=... exécutable'
@echo ' make test Test.' @echo ' make exec_version exécutable'
@echo ' make test Test' @echo ' make test Test'
@echo ' make clean Clean the directory tree.' @echo ' make clean Clean the directory tree.'
@echo @echo
@echo ' DATE ${DATE}'
@echo ' GOVERSION ${GOVERSION}'
@echo ' VERSION ${VERSION}'
@echo
${BIN_DIR}/${BIN_NAME}: ${SOURCES} $(OBJS) ${BIN_DIR}/${BIN_NAME}: ${SOURCES} $(OBJS)
go build -o ${BIN_DIR}/${BIN_NAME} go build -o ${BIN_DIR}/${BIN_NAME} -ldflags ${LDFLAGS}
get-deps: get-deps:
@go mod tidy @go mod tidy
build: ${BIN_DIR}/${BIN_NAME} build: ${BIN_DIR}/${BIN_NAME}
run: $(OBJS) run:
@go run main.go ${BIN_OPTS} @go run main.go ${BIN_OPTS}
run_generate: $(OBJS) run_generate:
@go run main.go generate ${BIN_OPTS} @go run main.go generate ${BIN_OPTS}
run_install: $(OBJS) run_install:
@go run main.go install ${BIN_OPTS} @go run main.go install ${BIN_OPTS}
run_uninstall: $(OBJS) run_uninstall:
@go run main.go uninstall ${BIN_OPTS} @go run main.go uninstall ${BIN_OPTS}
run_version:
@go run main.go version
exec: ${BIN_DIR}/${BIN_NAME} $(OBJS) exec: ${BIN_DIR}/${BIN_NAME} $(OBJS)
@${BIN_DIR}/${BIN_NAME} ${BIN_OPTS} @${BIN_DIR}/${BIN_NAME} ${BIN_OPTS}
@@ -61,6 +80,9 @@ exec_install: ${BIN_DIR}/${BIN_NAME} $(OBJS)
exec_uninstall: ${BIN_DIR}/${BIN_NAME} $(OBJS) exec_uninstall: ${BIN_DIR}/${BIN_NAME} $(OBJS)
@${BIN_DIR}/${BIN_NAME} uninstall ${BIN_OPTS} @${BIN_DIR}/${BIN_NAME} uninstall ${BIN_OPTS}
exec_version: ${BIN_DIR}/${BIN_NAME} $(OBJS)
@${BIN_DIR}/${BIN_NAME} version
clean: clean:
@test ! -e ${BIN_DIR}/${BIN_NAME} || rm ${BIN_DIR}/${BIN_NAME} @test ! -e ${BIN_DIR}/${BIN_NAME} || rm ${BIN_DIR}/${BIN_NAME}
@test ! -e .coverage.out || rm .coverage.out @test ! -e .coverage.out || rm .coverage.out

58
src/README.md Normal file
View File

@@ -0,0 +1,58 @@
# Purpose
**oc-deploy** is a tool to deploy (with **helm**) all component of **OpenCloud**.
# Development
To init:
```
make get-deps
```
## To build
```
make build
```
## To run
```
make run_install [BIN_OPTS="<args>"]
make run_uninstall [BIN_OPTS="<args>"]
make run_generate [BIN_OPTS="<args>"]
```
or
```
make exec_install [BIN_OPTS="<args>"]
make exec_uninstall [BIN_OPTS="<args>"]
make exec_generate [BIN_OPTS="<args>"]
```
# To Test
All packages:
```
make test
```
or to test an specific package:
```
make test_<package>
```
Test generate _.coverage.html_ file to view the coverage of test.
## To Publish
Cf : ../publish
## Divers
* Latest version for _kubectl_: https://dl.k8s.io/release/stable.txt
* Release for _helm_: https://github.com/helm/helm/releases

View File

@@ -12,28 +12,37 @@ type ChartData struct {
Version string `yaml:"version"` Version string `yaml:"version"`
Opts string `yaml:"helm_opts"` Opts string `yaml:"helm_opts"`
Values string `yaml:"helm_values"` Values map[string]string `yaml:"helm_values"`
FileValues string `yaml:"helm_filevalues"` FileValues []string `yaml:"helm_filevalues"`
Overwrite string `yaml:"helm_overwrite"`
} }
type repoData struct { type repoData struct {
Name string `yaml:"name"` Name string `yaml:"name"`
Url string `yaml:"url"` Url string `yaml:"url"`
ForceUpdate bool `yaml:"forceupdate"` ForceUpdate bool `yaml:"forceupdate"`
Opts string `yaml:"opts"`
}
type ociData struct {
Url string `yaml:"url"`
} }
type ChartRepoData struct { type ChartRepoData struct {
Repository repoData `yaml:"repository"` Repository repoData `yaml:"repository"`
Oci ociData `yaml:"oci"`
Charts []ChartData `yaml:"charts"` Charts []ChartData `yaml:"charts"`
} }
type chartsRepoData struct { type chartsRepoParse struct {
Charts []ChartRepoData `yaml:"opencloud"` Charts []ChartRepoData `yaml:"opencloud"`
} }
func FromConfigFile(filename string) ([]ChartRepoData, error) { func FromConfigFile(filename string) ([]ChartRepoData, error) {
yamlFile, _ := os.ReadFile(filename) yamlFile, _ := os.ReadFile(filename)
var data chartsRepoData
var data chartsRepoParse
err := yaml.Unmarshal(yamlFile, &data) err := yaml.Unmarshal(yamlFile, &data)
if err != nil { if err != nil {
return data.Charts, err return data.Charts, err

View File

@@ -1,7 +1,5 @@
package chart package chart
// https://pkg.go.dev/github.com/stretchr/testify/assert
import ( import (
"testing" "testing"
"path/filepath" "path/filepath"
@@ -9,7 +7,7 @@ import (
) )
func TestReadConfChart(t *testing.T){ func _TestReadConfChart(t *testing.T) {
src := filepath.Join(TEST_SRC_DIR, "oc.yml") src := filepath.Join(TEST_SRC_DIR, "oc.yml")
assert.FileExists(t, src, "FromConfigFile error") assert.FileExists(t, src, "FromConfigFile error")
@@ -22,11 +20,15 @@ func TestReadConfChart(t *testing.T){
assert.Equal(t, "wordpress", wordpress.Name, "FromConfigFile error") assert.Equal(t, "wordpress", wordpress.Name, "FromConfigFile error")
assert.Equal(t, "bitnami/wordpress", wordpress.Chart, "FromConfigFile error") assert.Equal(t, "bitnami/wordpress", wordpress.Chart, "FromConfigFile error")
assert.Equal(t, "23.1.0", wordpress.Version, "FromConfigFile error") assert.Equal(t, "23.1.0", wordpress.Version, "FromConfigFile error")
assert.Equal(t, 0, len(wordpress.FileValues), "FromConfigFile error")
assert.Equal(t, 0, len(wordpress.Values), "FromConfigFile error")
phpmyadmin := data[0].Charts[1] phpmyadmin := data[0].Charts[1]
assert.Equal(t, "phpmyadmin", phpmyadmin.Name, "FromConfigFile error") assert.Equal(t, "phpmyadmin", phpmyadmin.Name, "FromConfigFile error")
assert.Equal(t, "bitnami/phpmyadmin", phpmyadmin.Chart,"FromConfigFile error") assert.Equal(t, "bitnami/phpmyadmin", phpmyadmin.Chart,"FromConfigFile error")
assert.Equal(t, "17.0.4", phpmyadmin.Version, "FromConfigFile error") assert.Equal(t, "17.0.4", phpmyadmin.Version, "FromConfigFile error")
assert.Equal(t, 2, len(phpmyadmin.FileValues), "FromConfigFile error")
assert.Equal(t, 1, len(phpmyadmin.Values), "FromConfigFile error")
data1 := data[1] data1 := data[1]
assert.Equal(t, "", data1.Repository.Name, "FromConfigFile error") assert.Equal(t, "", data1.Repository.Name, "FromConfigFile error")
@@ -35,5 +37,27 @@ func TestReadConfChart(t *testing.T){
myfirstrelease := data1.Charts[0] myfirstrelease := data1.Charts[0]
assert.Equal(t, "myfirstrelease", myfirstrelease.Name, "FromConfigFile error") assert.Equal(t, "myfirstrelease", myfirstrelease.Name, "FromConfigFile error")
assert.Equal(t, "https://zzzz/myfirstchart-0.1.0.tgz", myfirstrelease.Url, "FromConfigFile error") assert.Equal(t, "https://zzzz/myfirstchart-0.1.0.tgz", myfirstrelease.Url, "FromConfigFile error")
}
func _TestReadConfChartOverwrite(t *testing.T){
src := filepath.Join(TEST_SRC_DIR, "oc_overwrite.yml")
assert.FileExists(t, src, "FromConfigFile error")
data, _ := FromConfigFile(src)
// Nombre de lettres
assert.Equal(t, 70, len(data[0].Charts[0].Overwrite), "TestReadConfChartOverwrite error")
}
func TestReadConfChartOci(t *testing.T) {
src := filepath.Join(TEST_SRC_DIR, "oc_oci.yml")
assert.FileExists(t, src, "FromConfigFile error")
data, _ := FromConfigFile(src)
assert.Equal(t, "", data[0].Repository.Name, "FromConfigFile error")
assert.Equal(t, "oci://harbor.dtf/dev", data[0].Oci.Url, "FromConfigFile error")
} }

View File

@@ -24,9 +24,10 @@ func cobraInstallCmd() *cobra.Command {
Long: `deploy Charts`, Long: `deploy Charts`,
Args: cobra.MaximumNArgs(0), Args: cobra.MaximumNArgs(0),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
log.Log().Info().Msg("oc-deploy :")
return InstallCmd(context, version, modules) return InstallCmd(context, version, modules)
}, },
Example: "oc-deploy install --version 1.0 --context ex1", Example: "oc-deploy install --version 0.1.0 --context ex1",
} }
} }
@@ -37,7 +38,8 @@ func cobraUninstallCmd() *cobra.Command{
Long: `Undeploy`, Long: `Undeploy`,
Args: cobra.MaximumNArgs(0), Args: cobra.MaximumNArgs(0),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
return UninstallCmd(context) log.Log().Info().Msg("oc-deploy :")
return UninstallCmd(context, modules)
}, },
Example: "oc-deploy uninstall --context ex1", Example: "oc-deploy uninstall --context ex1",
} }
@@ -48,12 +50,26 @@ func cobraGenerateCmd() *cobra.Command{
return &cobra.Command{ return &cobra.Command{
Use: "generate", Use: "generate",
Short: "generate", Short: "generate",
Long: "Value", Long: "generate",
Args: cobra.MaximumNArgs(0), Args: cobra.MaximumNArgs(0),
RunE: func(cmd *cobra.Command, args []string) error { RunE: func(cmd *cobra.Command, args []string) error {
log.Log().Info().Msg("oc-deploy :")
return GenerateCmd(context, version) return GenerateCmd(context, version)
}, },
Example: "oc-deploy generate --version 1.0 --context ex1", Example: "oc-deploy generate --version 0.1.0 --context ex1",
}
}
func cobraVersionCmd() *cobra.Command{
return &cobra.Command{
Use: "version",
Short: "version",
Long: "Get Version",
Args: cobra.MaximumNArgs(0),
RunE: func(cmd *cobra.Command, args []string) error {
return VersionCmd()
},
Example: "oc-deploy version",
} }
} }
@@ -66,12 +82,14 @@ func Execute() {
var cmdInstall = cobraInstallCmd() var cmdInstall = cobraInstallCmd()
var cmdUninstall = cobraUninstallCmd() var cmdUninstall = cobraUninstallCmd()
var cmdGenerate = cobraGenerateCmd() var cmdGenerate = cobraGenerateCmd()
var cmdVersion = cobraVersionCmd()
cmdInstall.Flags().StringVarP(&context, "context", "c", "opencloud", "Nom du context") cmdInstall.Flags().StringVarP(&context, "context", "c", "opencloud", "Nom du context")
cmdInstall.Flags().StringVarP(&version, "version", "v", "latest", "Version") cmdInstall.Flags().StringVarP(&version, "version", "v", "latest", "Version")
cmdInstall.Flags().StringArrayVarP(&modules, "modules", "m", []string{}, "modules, ...") cmdInstall.Flags().StringArrayVarP(&modules, "modules", "m", []string{}, "modules, ...")
cmdUninstall.Flags().StringVarP(&context, "context", "c", "opencloud", "Nom du context") cmdUninstall.Flags().StringVarP(&context, "context", "c", "opencloud", "Nom du context")
cmdUninstall.Flags().StringArrayVarP(&modules, "modules", "m", []string{}, "modules, ...")
cmdGenerate.Flags().StringVarP(&context, "context", "c", "opencloud", "Nom du context") cmdGenerate.Flags().StringVarP(&context, "context", "c", "opencloud", "Nom du context")
cmdGenerate.Flags().StringVarP(&version, "version", "v", "latest", "Version") cmdGenerate.Flags().StringVarP(&version, "version", "v", "latest", "Version")
@@ -79,6 +97,7 @@ func Execute() {
rootCmd.AddCommand(cmdInstall) rootCmd.AddCommand(cmdInstall)
rootCmd.AddCommand(cmdUninstall) rootCmd.AddCommand(cmdUninstall)
rootCmd.AddCommand(cmdGenerate) rootCmd.AddCommand(cmdGenerate)
rootCmd.AddCommand(cmdVersion)
cobra.CheckErr(rootCmd.Execute()) cobra.CheckErr(rootCmd.Execute())

View File

@@ -1,28 +1,23 @@
package cmd package cmd
import ( import (
"fmt"
log "oc-deploy/log_wrapper" log "oc-deploy/log_wrapper"
"oc-deploy/versionOc" // "oc-deploy/versionOc"
"oc-deploy/generate" "oc-deploy/install"
) )
func GenerateCmd(project string, version string) error { func GenerateCmd(prcontextoject string, version string) error {
log.Log().Info().Msg("Generate >> ") log.Log().Info().Msg("Generate >> ")
version, err := versionOc.GetFromFile(version) workspace := fmt.Sprintf("workspace_%s", context)
if err != nil {
log.Log().Fatal().Msg("OpenCloud >> " + err.Error())
}
log.Log().Info().Msg(" >> Version : " + version)
obj := generate.GenerateClass{Workspace: "workspace_" + project, Version: version} obj := install.InstallClass{Workspace: workspace, Version: version}
fic, err := obj.New() _, err := obj.NewGenerate()
if err != nil { if err != nil {
log.Log().Fatal().Msg(" >> " + err.Error()) log.Log().Fatal().Msg(" >> " + err.Error())
} }
log.Log().Info().Msg(" >> Value : " + fic)
return err return err
} }

View File

@@ -2,19 +2,19 @@ package cmd
import ( import (
"fmt" "fmt"
// "strings"
// "github.com/spf13/cobra"
log "oc-deploy/log_wrapper" log "oc-deploy/log_wrapper"
// "oc-deploy/versionOc"
"oc-deploy/install" "oc-deploy/install"
) )
func UninstallCmd(context string) error { func UninstallCmd(context string, modules []string) error {
log.Log().Info().Msg("Uninstall >> ") log.Log().Info().Msg("Uninstall >> ")
log.Log().Info().Msg(" << Contexte : " + context) log.Log().Info().Msg(" << Contexte : " + context)
if len(modules) > 0 {
log.Log().Info().Msg(fmt.Sprintf(" << Modules : %s", modules))
}
workspace := fmt.Sprintf("workspace_%s", context) workspace := fmt.Sprintf("workspace_%s", context)
obj := install.InstallClass{Workspace: workspace} obj := install.InstallClass{Workspace: workspace}
@@ -31,12 +31,14 @@ func UninstallCmd(context string) error {
log.Log().Fatal().Msg(" >> " + err.Error()) log.Log().Fatal().Msg(" >> " + err.Error())
} }
obj.SetCommands()
err = obj.K8s(context) err = obj.K8s(context)
if err != nil { if err != nil {
log.Log().Fatal().Msg(" >> " + err.Error()) log.Log().Fatal().Msg(" >> " + err.Error())
} }
err = obj.UninstallCharts() err = obj.UninstallCharts(modules)
if err != nil { if err != nil {
log.Log().Fatal().Msg(" >> " + err.Error()) log.Log().Fatal().Msg(" >> " + err.Error())
} }

19
src/cmd/versionCmd.go Normal file
View File

@@ -0,0 +1,19 @@
package cmd
import (
"fmt"
"oc-deploy/occonst"
log "oc-deploy/log_wrapper"
)
func VersionCmd() error {
version := occonst.Version
date := occonst.Date
goversion := occonst.GoVersion
log.Log().Debug().Msg(fmt.Sprintf("Version : %s (%s) ; GoVersion : %s", version, date, goversion))
fmt.Println(version)
return nil
}

View File

@@ -1,22 +0,0 @@
package generate
import (
"fmt"
"oc-deploy/utils"
)
type GenerateClass struct {
Version string
Workspace string
}
func (this GenerateClass) New() (string, error) {
src := fmt.Sprintf("../offline/default_value_%s.yml", this.Version)
dst := fmt.Sprintf("%s/default_value.yml", this.Workspace)
err := utils.CopyFile(src, dst)
if err != nil {
return "", err
}
return src, nil
}

View File

@@ -1,162 +1,169 @@
package helm package helm
import ( import (
"fmt" "fmt"
"strconv" "strconv"
"os" "os"
"strings" "strings"
"errors" "errors"
"path/filepath" "path/filepath"
"encoding/json" "encoding/json"
log "oc-deploy/log_wrapper" log "oc-deploy/log_wrapper"
) )
type HelmChart struct { type HelmChart struct {
Bin string Bin string
Name string Name string
Chart string Chart string
Version string Version string
Url string Url string
Workspace string Workspace string
Opts string Opts string
Values string Values map[string]string
FileValues string FileValues []string
} }
type installInfoOutput struct { type installInfoOutput struct {
Description string `json:"description"` Description string `json:"description"`
Notes string `json:"notes"` Notes string `json:"notes"`
Status string `json:"status"` Status string `json:"status"`
} }
type installOutput struct { type installOutput struct {
Info installInfoOutput `json:"info"` Info installInfoOutput `json:"info"`
} }
func (this HelmCommand) ChartInstall(data HelmChart) (string, error) { func (this HelmCommand) ChartInstall(data HelmChart) (string, error) {
bin := this.Bin bin := this.Bin
existe, err := this.chartExists(data) existe, err := this.chartExists(data)
if err != nil { if err != nil {
return "", err return "", err
} }
if existe { if existe {
return "Existe déjà", nil return "Existe déjà", nil
} }
ficChart := data.Chart ficChart := data.Chart
// Recherche locale // Recherche locale
if _, err := os.Stat(ficChart); err != nil { if _, err := os.Stat(ficChart); err != nil {
} else { } else {
// Recherche voa le Workspace // Recherche voa le Workspace
ficChart := filepath.Join(data.Workspace, data.Chart) ficChart := filepath.Join(data.Workspace, data.Chart)
if _, err := os.Stat(ficChart); err == nil { if _, err := os.Stat(ficChart); err == nil {
} else { } else {
if data.Url != "" { if data.Url != "" {
fmt.Println("============ 52 Télechargement", data.Url) fmt.Println("============ 52 Télechargement", data.Url)
} }
} }
} }
msg := fmt.Sprintf("%s install %s %s %s --output json", bin, data.Name, ficChart, data.Opts) msg := fmt.Sprintf("%s install %s %s %s --output json", bin, data.Name, ficChart, data.Opts)
if data.Version != "" { if data.Version != "" {
msg = fmt.Sprintf("%s --version %s", msg, data.Version) msg = fmt.Sprintf("%s --version %s", msg, data.Version)
} }
if data.FileValues != "" { for key, value := range data.Values {
fic := filepath.Join(data.Workspace, data.FileValues) msg = fmt.Sprintf("%s --set %s=%s", msg, key, value)
if _, err := os.Stat(fic); err != nil { }
log.Log().Warn().Msg(fic)
} else { ficoverwrite := filepath.Join(data.Workspace, fmt.Sprintf("value-%s.yml", data.Name))
msg = fmt.Sprintf("%s --values %s", msg, fic) if _, err := os.Stat(ficoverwrite); err != nil {
} log.Log().Warn().Msg(ficoverwrite)
} } else {
msg = fmt.Sprintf("%s --values %s", msg, ficoverwrite)
msg = strings.Replace(msg, " ", " ", -1) }
log.Log().Debug().Msg(msg) for _, valuefilename := range data.FileValues {
fic := filepath.Join(data.Workspace, valuefilename)
cmd_args := strings.Split(msg, " ") if _, err := os.Stat(fic); err != nil {
cmd := this.Exec(cmd_args[0], cmd_args[1:]...) log.Log().Warn().Msg(fic)
stdout, err := cmd.CombinedOutput() } else {
msg = fmt.Sprintf("%s --values %s", msg, fic)
if err != nil { }
res := string(stdout) }
res = strings.TrimSuffix(res, "\n")
return "", errors.New(res) msg = strings.Replace(msg, " ", " ", -1)
}
log.Log().Debug().Msg(msg)
var objmap installOutput
cmd_args := strings.Split(msg, " ")
err = json.Unmarshal(stdout, &objmap) cmd := this.Exec(cmd_args[0], cmd_args[1:]...)
if err != nil { stdout, err := cmd.CombinedOutput()
return "", err
} if err != nil {
res := string(stdout)
res := objmap.Info.Status res = strings.TrimSuffix(res, "\n")
return "", errors.New(res)
return res, nil }
}
var objmap installOutput
func (this HelmCommand) ChartUninstall(data HelmChart) (string, error) {
bin := this.Bin i := strings.Index(string(stdout), "{")
stdout2 := string(stdout)[i:]
log.Log().Info().Msg(" >> Chart : " + data.Name)
err = json.Unmarshal([]byte(stdout2), &objmap)
existe, err := this.chartExists(data) if err != nil {
if err != nil { return "", err
return "", err }
}
if ! existe { res := objmap.Info.Status
return "Non présent", nil
} return res, nil
}
msg := fmt.Sprintf("%s uninstall %s", bin, data.Name)
log.Log().Debug().Msg(msg) func (this HelmCommand) ChartUninstall(data HelmChart) (string, error) {
bin := this.Bin
cmd_args := strings.Split(msg, " ")
cmd := this.Exec(cmd_args[0], cmd_args[1:]...) log.Log().Info().Msg(" >> Chart : " + data.Name)
stdout, err := cmd.CombinedOutput()
existe, err := this.chartExists(data)
res := string(stdout) if err != nil {
res = strings.TrimSuffix(res, "\n") return "", err
}
log.Log().Debug().Msg(res) if ! existe {
return "Non présent", nil
return res, err }
}
msg := fmt.Sprintf("%s uninstall %s", bin, data.Name)
// ../bin/helm list --filter phpmyadminm --short log.Log().Debug().Msg(msg)
func (this HelmCommand) chartExists(data HelmChart) (bool, error) {
bin := this.Bin cmd_args := strings.Split(msg, " ")
cmd := this.Exec(cmd_args[0], cmd_args[1:]...)
msg := fmt.Sprintf("%s list --filter %s --no-headers", bin, data.Name) stdout, err := cmd.CombinedOutput()
log.Log().Debug().Msg(msg)
res := string(stdout)
cmd_args := strings.Split(msg, " ") res = strings.TrimSuffix(res, "\n")
cmd := this.Exec(cmd_args[0], cmd_args[1:]...)
stdout, err := cmd.CombinedOutput() log.Log().Debug().Msg(res)
if err != nil {
log.Log().Debug().Msg(string(stdout)) return res, err
return false, errors.New(string(stdout)) }
}
// ../bin/helm list --filter phpmyadminm --short
res := string(stdout) func (this HelmCommand) chartExists(data HelmChart) (bool, error) {
res = strings.TrimSuffix(res, "\n")
bin := this.Bin
log.Log().Debug().Msg(string(stdout))
log.Log().Debug().Msg(strconv.FormatBool(res != "")) msg := fmt.Sprintf("%s list --filter %s --no-headers", bin, data.Name)
log.Log().Debug().Msg(msg)
return res != "", nil
} cmd_args := strings.Split(msg, " ")
cmd := this.Exec(cmd_args[0], cmd_args[1:]...)
// func (this HelmChart) GetRessources() (map[string]string, error) { stdout, err := cmd.CombinedOutput()
// hs := HelmStatus{Name: this.Name} if err != nil {
// hs.New(this.Bin) log.Log().Debug().Msg(string(stdout))
// data, _ := hs.getRessources() return false, errors.New(string(stdout))
}
// return data, nil
// } res := string(stdout)
res = strings.TrimSuffix(res, "\n")
log.Log().Debug().Msg(string(stdout))
log.Log().Debug().Msg(strconv.FormatBool(res != ""))
return res != "", nil
}

View File

@@ -1,98 +1,102 @@
package helm package helm
import ( import (
"fmt" "fmt"
"strings" "strings"
"encoding/json" "encoding/json"
log "oc-deploy/log_wrapper" log "oc-deploy/log_wrapper"
"oc-deploy/utils" "oc-deploy/utils"
) )
type HelmRepo struct { type HelmRepo struct {
Name string Name string
Repository string // Url du dépôt Repository string // Url du dépôt
ForceUpdate bool ForceUpdate bool
Opts string Opts string
} }
func (this HelmCommand) AddRepository(repo HelmRepo) (string, error) { func (this HelmCommand) AddRepository(repo HelmRepo) (string, error) {
helm_bin := this.Bin helm_bin := this.Bin
force_update := "--force-update=false" force_update := "--force-update=false"
if repo.ForceUpdate { if repo.ForceUpdate {
force_update = "--force-update=true" force_update = "--force-update=true"
} else { } else {
list, _ := this.ListRepository() list, _ := this.ListRepository()
if utils.StringInSlice(repo.Name, list) { if utils.StringInSlice(repo.Name, list) {
return "Existe déjà", nil return "Existe déjà", nil
} }
} }
msg := fmt.Sprintf("%s repo add %s %s %s %s", helm_bin, repo.Name, repo.Repository, force_update, repo.Opts) msg := fmt.Sprintf("%s repo add %s %s %s %s", helm_bin, repo.Name, repo.Repository, force_update, repo.Opts)
log.Log().Debug().Msg(msg)
msg = strings.TrimSuffix(msg, " ")
msg = strings.TrimSuffix(msg, " ") log.Log().Debug().Msg(msg)
cmd_args := strings.Split(msg, " ") cmd_args := strings.Split(msg, " ")
cmd := this.Exec(cmd_args[0], cmd_args[1:]...) cmd := this.Exec(cmd_args[0], cmd_args[1:]...)
stdout, err := cmd.CombinedOutput() stdout, err := cmd.CombinedOutput()
if err != nil {
res := string(stdout) return "", fmt.Errorf(string(stdout))
res = strings.TrimSuffix(res, "\n") }
return res, err res := string(stdout)
} res = strings.TrimSuffix(res, "\n")
log.Log().Debug().Msg(res)
type parseList struct {
Name string `json:"name"` return res, nil
} }
func (this HelmCommand) ListRepository() ([]string, error) { type parseList struct {
Name string `json:"name"`
helm_bin := this.Bin }
res := make([]string, 0, 0)
func (this HelmCommand) ListRepository() ([]string, error) {
msg := fmt.Sprintf("%s repo list -o json", helm_bin)
log.Log().Debug().Msg(msg) helm_bin := this.Bin
res := make([]string, 0, 0)
cmd_args := strings.Split(msg, " ")
msg := fmt.Sprintf("%s repo list -o json", helm_bin)
cmd := this.Exec(cmd_args[0], cmd_args[1:]...) log.Log().Debug().Msg(msg)
stdout, err := cmd.CombinedOutput()
if err != nil { cmd_args := strings.Split(msg, " ")
return res, err
} cmd := this.Exec(cmd_args[0], cmd_args[1:]...)
stdout, err := cmd.CombinedOutput()
var objmap []parseList if err != nil {
return res, err
err = json.Unmarshal(stdout, &objmap) }
if err != nil {
return res, err var objmap []parseList
}
err = json.Unmarshal(stdout, &objmap)
for _, ele := range objmap { if err != nil {
res = append(res, ele.Name) return res, err
} }
return res, err for _, ele := range objmap {
} res = append(res, ele.Name)
}
// helm repo remove [NAME]
func (this HelmCommand) RemoveRepository(repo HelmRepo) (string, error) { return res, err
helm_bin := this.Bin }
msg := fmt.Sprintf("%s repo remove %s", helm_bin, repo.Name) // helm repo remove [NAME]
log.Log().Debug().Msg(msg) func (this HelmCommand) RemoveRepository(repo HelmRepo) (string, error) {
helm_bin := this.Bin
cmd_args := strings.Split(msg, " ")
msg := fmt.Sprintf("%s repo remove %s", helm_bin, repo.Name)
cmd := this.Exec(cmd_args[0], cmd_args[1:]...) log.Log().Debug().Msg(msg)
stdout, err := cmd.CombinedOutput()
cmd_args := strings.Split(msg, " ")
res := string(stdout)
res = strings.TrimSuffix(res, "\n") cmd := this.Exec(cmd_args[0], cmd_args[1:]...)
stdout, err := cmd.CombinedOutput()
return res, err
} res := string(stdout)
res = strings.TrimSuffix(res, "\n")
return res, err
}

View File

@@ -1,32 +1,28 @@
package helm package helm
import ( import (
"fmt" "fmt"
"strings" "strings"
"errors" "errors"
log "oc-deploy/log_wrapper" log "oc-deploy/log_wrapper"
) )
// type HelmData struct { func (this HelmCommand) Status(data HelmChart) (string, error) {
// Name string
// } helm_bin := this.Bin
func (this HelmCommand) Status(data HelmChart) (string, error) { msg := fmt.Sprintf("%s status %s --show-resources -o json", helm_bin, data.Name)
log.Log().Debug().Msg(msg)
helm_bin := this.Bin
cmd_args := strings.Split(msg, " ")
msg := fmt.Sprintf("%s status %s --show-resources -o json", helm_bin, data.Name)
log.Log().Debug().Msg(msg) cmd := this.Exec(cmd_args[0], cmd_args[1:]...)
stdout, err := cmd.CombinedOutput()
cmd_args := strings.Split(msg, " ") if err != nil {
log.Log().Debug().Msg(string(stdout))
cmd := this.Exec(cmd_args[0], cmd_args[1:]...) return "", errors.New(string(stdout))
stdout, err := cmd.CombinedOutput() }
if err != nil {
log.Log().Debug().Msg(string(stdout)) return string(stdout), nil
return "", errors.New(string(stdout)) }
}
return string(stdout), nil
}

View File

@@ -2,14 +2,30 @@ package install
import ( import (
"fmt" "fmt"
"os"
"errors" "errors"
log "oc-deploy/log_wrapper" log "oc-deploy/log_wrapper"
"oc-deploy/tool" "oc-deploy/tool"
"oc-deploy/chart"
"oc-deploy/kubectl" "oc-deploy/kubectl"
"oc-deploy/helm" "oc-deploy/helm"
"oc-deploy/versionOc"
"oc-deploy/utils"
) )
type InstallClass struct {
Version string
Workspace string
tools []tool.ToolData
toolsBin map[string]string
charts []chart.ChartRepoData
commandHelm helm.HelmCommand
commandKubectl kubectl.KubectlCommand
}
func (this *InstallClass) Tools() (error) { func (this *InstallClass) Tools() (error) {
var mem []tool.ToolClass var mem []tool.ToolClass
@@ -59,10 +75,6 @@ func (this *InstallClass) SetCommands() {
this.commandKubectl.New() this.commandKubectl.New()
} }
// func (this *InstallClass) SetCommandsMock(mock helm.HelmCommandInterface) {
// this.commandHelm = mock
// }
func (this *InstallClass) getToolBin(name string) (string, error) { func (this *InstallClass) getToolBin(name string) (string, error) {
for key, value := range this.toolsBin { for key, value := range this.toolsBin {
if key == name { if key == name {
@@ -102,3 +114,32 @@ func (this *InstallClass) K8s(context string) (error) {
return nil return nil
} }
func (this *InstallClass) extractVersion() (string, error) {
// Extraction du fichier de version
dst := fmt.Sprintf("%s/oc.yml", this.Workspace)
log.Log().Debug().Msg(fmt.Sprintf("Check du fichier de version : %s", dst))
if _, err := os.Stat(dst); err == nil {
log.Log().Debug().Msg("Existe déjà")
version, err := versionOc.GetFromFile(dst)
if err != nil {
return "", err
}
this.Version = version
} else {
log.Log().Debug().Msg("Téléchargement du fichier de version "+ this.Version)
version, fileversion, err := versionOc.GetFromOnline(this.Version)
if err != nil {
return "", err
}
this.Version = version
err = utils.CopyContentFile(fileversion, dst)
if err != nil {
return "", err
}
}
return dst, nil
}

36
src/install/generate.go Normal file
View File

@@ -0,0 +1,36 @@
package install
import (
"fmt"
"path/filepath"
log "oc-deploy/log_wrapper"
"oc-deploy/utils"
"oc-deploy/chart"
)
func (this *InstallClass) NewGenerate() (string, error) {
// Extraction du fichier de la version
dst, err := this.extractVersion()
if err != nil {
return "", err
}
this.charts, _ = chart.FromConfigFile(dst)
if err != nil {
return dst, err
}
for _, ele1 := range this.charts {
for _, ele2 := range ele1.Charts {
filename := filepath.Join(this.Workspace, fmt.Sprintf("values-%s.yml", ele2.Name) )
utils.CopyContentFile(ele2.Overwrite, filename)
log.Log().Info().Msg(fmt.Sprintf(">> %s : %s", ele2.Name, filename))
}
}
return dst, nil
}

View File

@@ -3,7 +3,6 @@ package install
import ( import (
"fmt" "fmt"
"sync" "sync"
"os"
log "oc-deploy/log_wrapper" log "oc-deploy/log_wrapper"
"oc-deploy/utils" "oc-deploy/utils"
@@ -11,50 +10,17 @@ import (
"oc-deploy/chart" "oc-deploy/chart"
"oc-deploy/helm" "oc-deploy/helm"
"oc-deploy/kubectl" "oc-deploy/kubectl"
"oc-deploy/versionOc"
) )
type InstallClass struct {
Version string
Workspace string
tools []tool.ToolData
toolsBin map[string]string
charts []chart.ChartRepoData
commandHelm helm.HelmCommand
commandKubectl kubectl.KubectlCommand
}
func (this *InstallClass) NewInstall() (string, error) { func (this *InstallClass) NewInstall() (string, error) {
// Extraction du fichier de version // Extraction du fichier de la version
dst := fmt.Sprintf("%s/oc.yml", this.Workspace) dst, err := this.extractVersion()
log.Log().Debug().Msg(fmt.Sprintf("Check du fichier de version : %s", dst)) if err != nil {
if _, err := os.Stat(dst); err == nil { return "", err
log.Log().Debug().Msg("Existe déjà")
version, err := versionOc.GetFromFile(dst)
if err != nil {
return "", err
}
this.Version = version
} else {
log.Log().Debug().Msg("Téléchargement du fichier de version")
// version, fileversion, err := versionOc.Get(this.Version)
version, fileversion, err := versionOc.GetFromOnline(this.Version)
if err != nil {
return "", err
}
this.Version = version
err = utils.CopyContentFile(fileversion, dst)
if err != nil {
return "", err
}
} }
// Lecture du fichier de conf // Lecture du fichier de conf
var err error
this.tools, err = tool.FromConfigFile(dst) this.tools, err = tool.FromConfigFile(dst)
if err != nil { if err != nil {
return dst, err return dst, err
@@ -64,9 +30,6 @@ func (this *InstallClass) NewInstall() (string, error) {
return dst, err return dst, err
} }
bin_path, _ := this.getToolBin("helm")
fmt.Println("Install 67 bin_path", bin_path)
return dst, nil return dst, nil
} }
@@ -78,7 +41,8 @@ func (this *InstallClass) ChartRepo() (error) {
log.Log().Info().Msg(fmt.Sprintf(" >> Helm Repo : %s", v.Repository.Name)) log.Log().Info().Msg(fmt.Sprintf(" >> Helm Repo : %s", v.Repository.Name))
repo := helm.HelmRepo{Name: v.Repository.Name, repo := helm.HelmRepo{Name: v.Repository.Name,
Repository: v.Repository.Url, Repository: v.Repository.Url,
ForceUpdate: v.Repository.ForceUpdate} ForceUpdate: v.Repository.ForceUpdate,
Opts: v.Repository.Opts}
res, err := this.commandHelm.AddRepository(repo) res, err := this.commandHelm.AddRepository(repo)
if err != nil { if err != nil {
log.Log().Info().Msg(fmt.Sprintf(" << %s ", err)) log.Log().Info().Msg(fmt.Sprintf(" << %s ", err))
@@ -92,19 +56,26 @@ func (this *InstallClass) ChartRepo() (error) {
func (this *InstallClass) InstallCharts(modules []string) (error) { func (this *InstallClass) InstallCharts(modules []string) (error) {
// helm_bin, _ := this.getToolBin("helm")
// kubectl_bin, _ := this.getToolBin("kubectl")
var wg sync.WaitGroup var wg sync.WaitGroup
for _, v := range this.charts { for _, v := range this.charts {
repoName := ""
if v.Repository.Name != "" {
repoName = v.Repository.Name
} else {
if v.Oci.Url != "" {
repoName = v.Oci.Url
}
}
for _, v1 := range v.Charts { for _, v1 := range v.Charts {
if len(modules) == 0 || utils.StringInSlice(v1.Name, modules) { if len(modules) == 0 || utils.StringInSlice(v1.Name, modules) {
wg.Add(1) wg.Add(1)
go func() { go func() {
defer wg.Done() defer wg.Done()
this.installChart(v1) this.installChart(repoName, v1)
} () } ()
} }
} }
@@ -113,12 +84,19 @@ func (this *InstallClass) InstallCharts(modules []string) (error) {
return nil return nil
} }
func (this *InstallClass) installChart(chart chart.ChartData) { func (this *InstallClass) installChart(repoName string, chart chart.ChartData) {
log.Log().Info().Msg(fmt.Sprintf(" << Chart : %s ", chart.Name)) log.Log().Info().Msg(fmt.Sprintf(" << Chart : %s ", chart.Name))
chartName := chart.Chart
if chartName == "" {
chartName = chart.Name
}
if repoName != "" {
chartName = fmt.Sprintf("%s/%s", repoName, chartName)
}
data := helm.HelmChart{Name: chart.Name, data := helm.HelmChart{Name: chart.Name,
Chart: chart.Chart, Chart: chartName,
Url: chart.Url, Url: chart.Url,
Version: chart.Version, Version: chart.Version,
Workspace: this.Workspace, Workspace: this.Workspace,
@@ -126,7 +104,6 @@ func (this *InstallClass) installChart(chart chart.ChartData) {
Values: chart.Values, Values: chart.Values,
FileValues: chart.FileValues} FileValues: chart.FileValues}
res, err := this.commandHelm.ChartInstall(data) res, err := this.commandHelm.ChartInstall(data)
if err != nil { if err != nil {
log.Log().Error().Msg(fmt.Sprintf(" >> %s %s (%s)", data.Name, "KO", err)) log.Log().Error().Msg(fmt.Sprintf(" >> %s %s (%s)", data.Name, "KO", err))

Some files were not shown because too many files have changed in this diff Show More