Skip to content

Commit

Permalink
Merge pull request #137 from leanix/release/6.2.0
Browse files Browse the repository at this point in the history
[RELEASE]: Support Helm Release name for resources
  • Loading branch information
SudharmaPuranikLeanIX authored Jan 3, 2022
2 parents a77f007 + 9cf2410 commit 386d225
Show file tree
Hide file tree
Showing 13 changed files with 53 additions and 34 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# LeanIX Kubernetes Connector Changelog

## Release 2022-01-03 - 6.2.0
* To ensure support for multiple helm release on same cluster, all the existing K8s workloads are suffixed with the Helm release name.
* Support multiple workspace ID for same cluster via different helm releases

## Release 2021-12-08 - 6.1.0
* Breaking changes! Follow the below migration docs to upgrade from 6.0.3 to 6.1.0

Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PROJECT ?= leanix-k8s-connector
DOCKER_NAMESPACE ?= leanixacrpublic.azurecr.io

VERSION := 6.1.0
VERSION := 6.2.0
FULL_VERSION := $(VERSION)-$(shell git describe --tags --always)

IMAGE := $(DOCKER_NAMESPACE)/$(PROJECT):$(VERSION)
Expand Down
4 changes: 2 additions & 2 deletions cmd/leanix-k8s-connector/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,7 @@ func main() {
_, err = leanix.UpdateFailedProgressStatus(startResponse.ProgressCallbackUrl, "Failed to create uploader for backend storage")
log.Fatal(err)
}
err = uploader.UploadLdif(ldifByte)
err = uploader.UploadLdif(ldifByte, storage.LdifFileName+viper.GetString(lxWorkspaceFlag)+storage.LdifFileExtension)
if err != nil {
log.Fatal(err)
_, err := leanix.UpdateFailedProgressStatus(startResponse.ProgressCallbackUrl, "Failed to upload ldif to backend storage configured storage backend - "+viper.GetString("storage-backend"))
Expand All @@ -285,7 +285,7 @@ func main() {
}

log.Info("Uploading log file to configured backend storage")
err = uploader.UploadLog(debugLogBuffer.Bytes())
err = uploader.UploadLog(debugLogBuffer.Bytes(), storage.LogFileName+viper.GetString(lxWorkspaceFlag)+storage.LogFileExtension)
if err != nil {
log.Fatal(err)
}
Expand Down
34 changes: 22 additions & 12 deletions helm/index.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
apiVersion: v1
entries:
leanix-k8s-connector:
- apiVersion: v1
appVersion: 6.2.0
created: "2021-12-23T14:40:59.713818+01:00"
description: Retrieves information from Kubernetes cluster
digest: 5774478e89bc749ba21ec7f2477bb348788f2bbf6e8b76956eee5c4739de9e46
kubeVersion: '>= 1.19.0-0'
name: leanix-k8s-connector
urls:
- leanix-k8s-connector-6.2.0.tgz
version: 6.2.0
- apiVersion: v1
appVersion: 6.1.0
created: "2021-12-08T12:06:19.532135+01:00"
created: "2021-12-23T14:40:59.711566+01:00"
description: Retrieves information from Kubernetes cluster
digest: eabf3e49a9d4a0722228cb24872e6dfcc7b9db6b764bc714a74c0941f0d3ea4f
name: leanix-k8s-connector
Expand All @@ -12,7 +22,7 @@ entries:
version: 6.1.0
- apiVersion: v1
appVersion: 6.0.3
created: "2021-12-08T12:06:19.529601+01:00"
created: "2021-12-23T14:40:59.710467+01:00"
description: Retrieves information from Kubernetes cluster
digest: 5f1be6a80fc173d45ca60f5da8937abc0fcb2cc14652d6149d9ff2e405568a71
name: leanix-k8s-connector
Expand All @@ -21,7 +31,7 @@ entries:
version: 6.0.3
- apiVersion: v1
appVersion: 6.0.2
created: "2021-12-08T12:06:19.528574+01:00"
created: "2021-12-23T14:40:59.709385+01:00"
description: Retrieves information from Kubernetes cluster
digest: ccd112d1de601bfa796c4413ddc2b394f93ec4b66604338a736593168523b327
name: leanix-k8s-connector
Expand All @@ -30,7 +40,7 @@ entries:
version: 6.0.2
- apiVersion: v1
appVersion: 6.0.1
created: "2021-12-08T12:06:19.527459+01:00"
created: "2021-12-23T14:40:59.708288+01:00"
description: Retrieves information from Kubernetes cluster
digest: f3b959e24bdbf55314fa6d0a05681ec41dd34b1493b026a3450bf147e62a4b1b
name: leanix-k8s-connector
Expand All @@ -39,7 +49,7 @@ entries:
version: 6.0.1
- apiVersion: v1
appVersion: 6.0.0
created: "2021-12-08T12:06:19.521274+01:00"
created: "2021-12-23T14:40:59.70717+01:00"
description: Retrieves information from Kubernetes cluster
digest: c51f68b592c6f608a2f982e8c322280b8fc3aa4ac6ed0d823b2baf24b0877e6b
name: leanix-k8s-connector
Expand All @@ -48,7 +58,7 @@ entries:
version: 6.0.0
- apiVersion: v1
appVersion: 5.0.0
created: "2021-12-08T12:06:19.5199+01:00"
created: "2021-12-23T14:40:59.705136+01:00"
description: Retrieves information from Kubernetes cluster
digest: 549a753cf9875ca4eeaf5ecb5c64e76149b30bb8e82eee821f6c81cca27c37cf
name: leanix-k8s-connector
Expand All @@ -57,7 +67,7 @@ entries:
version: 5.0.0
- apiVersion: v1
appVersion: 4.0.0
created: "2021-12-08T12:06:19.516911+01:00"
created: "2021-12-23T14:40:59.704044+01:00"
description: Retrieves information from Kubernetes cluster
digest: adf5c8ef024857c4a0845a5c659f27bd7f21cdf568fff3445a192425c44fc9a8
name: leanix-k8s-connector
Expand All @@ -66,7 +76,7 @@ entries:
version: 4.0.0
- apiVersion: v1
appVersion: 3.0.0
created: "2021-12-08T12:06:19.513995+01:00"
created: "2021-12-23T14:40:59.703176+01:00"
description: Retrieves information from Kubernetes cluster
digest: 2927aebc215a1c5175e986135e36a10101e90fa69e7ab22a183049d086f7eddb
name: leanix-k8s-connector
Expand All @@ -75,7 +85,7 @@ entries:
version: 3.0.0
- apiVersion: v1
appVersion: 2.0.0
created: "2021-12-08T12:06:19.512623+01:00"
created: "2021-12-23T14:40:59.702333+01:00"
description: Retrieves information from Kubernetes cluster
digest: 3481723d2374757038495117518c47f634054408ccbd55112a6260d5a15e18c9
name: leanix-k8s-connector
Expand All @@ -84,7 +94,7 @@ entries:
version: 2.0.0
- apiVersion: v1
appVersion: 2.0.0-beta7
created: "2021-12-08T12:06:19.511567+01:00"
created: "2021-12-23T14:40:59.701445+01:00"
description: Retrieves information from Kubernetes cluster
digest: 0ade89d01236286f11ebf70290e2c4c82740fac11ec755be9dddd2375c74246f
name: leanix-k8s-connector
Expand All @@ -93,11 +103,11 @@ entries:
version: 2.0.0-beta7
- apiVersion: v1
appVersion: 1.1.0
created: "2021-12-08T12:06:19.51069+01:00"
created: "2021-12-23T14:40:59.700206+01:00"
description: Retrieves information from Kubernetes cluster
digest: aa3ee10eefe30e61e37058762b031bdee11cb9dd67afecdf6e831335d5c16e0f
name: leanix-k8s-connector
urls:
- leanix-k8s-connector-1.0.0.tgz
version: 1.0.0
generated: "2021-12-08T12:06:19.508107+01:00"
generated: "2021-12-23T14:40:59.698587+01:00"
Binary file added helm/leanix-k8s-connector-6.2.0.tgz
Binary file not shown.
5 changes: 3 additions & 2 deletions helm/leanix-k8s-connector/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
apiVersion: v1
appVersion: "6.1.0"
appVersion: "6.2.0"
description: Retrieves information from Kubernetes cluster
name: leanix-k8s-connector
version: 6.1.0
version: 6.2.0
kubeVersion: '>= 1.19.0-0'
2 changes: 1 addition & 1 deletion helm/leanix-k8s-connector/templates/clusterrole.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: leanix-k8s-connector
name: leanix-k8s-connector-{{ .Release.Name }}
labels:
{{ include "leanix-k8s-connector.labels" . | indent 4 }}
rules:
Expand Down
10 changes: 5 additions & 5 deletions helm/leanix-k8s-connector/templates/clusterrolebinding.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,22 @@
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: leanix-k8s-connector
name: leanix-k8s-connector-{{ .Release.Name }}
labels:
{{ include "leanix-k8s-connector.labels" . | indent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: leanix-k8s-connector
name: leanix-k8s-connector-{{ .Release.Name }}
subjects:
- kind: ServiceAccount
name: leanix-k8s-connector
name: leanix-k8s-connector-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: leanix-k8s-connector-view
name: leanix-k8s-connector-view-{{ .Release.Name }}
labels:
{{ include "leanix-k8s-connector.labels" . | indent 4 }}
roleRef:
Expand All @@ -26,6 +26,6 @@ roleRef:
name: view
subjects:
- kind: ServiceAccount
name: leanix-k8s-connector
name: leanix-k8s-connector-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
{{- end -}}
4 changes: 2 additions & 2 deletions helm/leanix-k8s-connector/templates/cronjob.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
apiVersion: batch/v1beta1
kind: CronJob
metadata:
name: {{ include "leanix-k8s-connector.fullname" . }}
name: {{ include "leanix-k8s-connector.fullname" . }}-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "leanix-k8s-connector.labels" . | indent 4 }}
Expand All @@ -18,7 +18,7 @@ spec:
cluster-autoscaler.kubernetes.io/safe-to-evict: "true"
spec:
{{- if .Values.rbac }}
serviceAccountName: leanix-k8s-connector
serviceAccountName: leanix-k8s-connector-{{ .Release.Name }}
{{- end }}
containers:
- name: connector
Expand Down
2 changes: 1 addition & 1 deletion helm/leanix-k8s-connector/templates/serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
apiVersion: v1
kind: ServiceAccount
metadata:
name: leanix-k8s-connector
name: leanix-k8s-connector-{{ .Release.Name }}
namespace: {{ .Release.Namespace }}
labels:
{{ include "leanix-k8s-connector.labels" . | indent 4 }}
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/azureblob.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ func NewAzureBlob(azureOpts *AzureBlobOpts) (*AzureContainer, error) {
}

// Upload uploads the LDIF file to azure blob storage
func (u *AzureContainer) UploadLdif(ldif []byte) error {
func (u *AzureContainer) UploadLdif(ldif []byte, LdifFileName string) error {
err := u.uploadFile(LdifFileName, ldif)
if err != nil {
return err
Expand All @@ -61,7 +61,7 @@ func (u *AzureContainer) UploadLdif(ldif []byte) error {
}

// Upload uploads the log file to azure blob storage
func (u *AzureContainer) UploadLog(log []byte) error {
func (u *AzureContainer) UploadLog(log []byte, LogFileName string) error {
err := u.uploadFile(LogFileName, log)
if err != nil {
return err
Expand Down
12 changes: 8 additions & 4 deletions pkg/storage/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,19 @@ const (
// FileStorage is a constant for the file storage identifier
FileStorage string = "file"
// LdifFileName is a constant for the file name used to store the ldif content
LdifFileName string = "kubernetes.ldif"
LdifFileName string = "kubernetes-"
// LdifFileExtension is a constant for Ldif file extension
LdifFileExtension string = ".ldif.json"
// LogFileName is a constant for the file name used to store the log output
LogFileName string = "leanix-k8s-connector.log"
LogFileName string = "leanix-k8s-connector-"
// LogFileExtension is a constant for Log file extension
LogFileExtension string = ".log"
)

// Backend exposes a common interface for all storage mechanisms
type Backend interface {
UploadLdif(ldif []byte) error
UploadLog(log []byte) error
UploadLdif(ldif []byte, fileName string) error
UploadLog(log []byte, fileName string) error
}

// NewBackend create a new storage backend for the given storage backend type
Expand Down
4 changes: 2 additions & 2 deletions pkg/storage/localfile.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ func NewLocalFile(path string) (*LocalFile, error) {
}

// Upload persists the ldif content in a local files
func (u *LocalFile) UploadLdif(ldif []byte) error {
func (u *LocalFile) UploadLdif(ldif []byte, LdifFileName string) error {
err := ioutil.WriteFile(path.Join(u.Path, LdifFileName), ldif, 0644)
if err != nil {
return err
Expand All @@ -42,7 +42,7 @@ func (u *LocalFile) UploadLdif(ldif []byte) error {
}

// Upload persists the the log file content in a local files
func (u *LocalFile) UploadLog(log []byte) error {
func (u *LocalFile) UploadLog(log []byte, LogFileName string) error {
err := ioutil.WriteFile(path.Join(u.Path, LogFileName), log, 0644)
if err != nil {
return err
Expand Down

0 comments on commit 386d225

Please sign in to comment.