From 83266a8994b37bd1796f0d75fbaaf922219e1663 Mon Sep 17 00:00:00 2001 From: Rudraksh Pareek Date: Wed, 20 Oct 2021 17:53:57 +0530 Subject: [PATCH 1/2] add appmesh-inject and gateway Signed-off-by: Rudraksh Pareek --- appmesh/error.go | 9 +++++++++ appmesh/install.go | 45 ++++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 51 insertions(+), 3 deletions(-) diff --git a/appmesh/error.go b/appmesh/error.go index 2a04cf9..adf1fb9 100644 --- a/appmesh/error.go +++ b/appmesh/error.go @@ -42,6 +42,10 @@ var ( // components ErrProcessOAMCode = "replace" + // ErrAddonFromTemplateCode represents the errors which are generated + // during addon deployment process + ErrAddonFromTemplateCode = "replace" + // ErrOpInvalid is an error when an invalid operation is requested ErrOpInvalid = errors.New(ErrOpInvalidCode, errors.Alert, []string{"Invalid operation"}, []string{}, []string{}, []string{}) @@ -104,3 +108,8 @@ func ErrAppMeshCoreComponentFail(err error) error { func ErrProcessOAM(err error) error { return errors.New(ErrProcessOAMCode, errors.Alert, []string{"error performing OAM operations"}, []string{err.Error()}, []string{}, []string{}) } + +// ErrAddonFromTemplate is the error for streaming event +func ErrAddonFromTemplate(err error) error { + return errors.New(ErrAddonFromTemplateCode, errors.Alert, []string{"Error with addon install operation"}, []string{err.Error()}, []string{}, []string{}) +} diff --git a/appmesh/install.go b/appmesh/install.go index 7c0e265..b09a02d 100644 --- a/appmesh/install.go +++ b/appmesh/install.go @@ -2,6 +2,8 @@ package appmesh import ( "fmt" + "strconv" + "strings" "github.com/layer5io/meshery-adapter-library/adapter" "github.com/layer5io/meshery-adapter-library/status" @@ -11,7 +13,9 @@ import ( const ( repo = "https://aws.github.io/eks-charts" - chart = "appmesh-controller" + appMeshController = "appmesh-controller" + appMeshInject = "appmesh-inject" + appMeshGateway = "appmesh-gateway" ) // Installs APP-MESH service mesh using helm charts. @@ -56,10 +60,12 @@ func (appMesh *AppMesh) applyHelmChart(del bool, version, namespace string) erro } else { act = mesherykube.INSTALL } + + // Install the controller err := kClient.ApplyHelmChart(mesherykube.ApplyHelmChartConfig{ ChartLocation: mesherykube.HelmChartLocation{ Repository: repo, - Chart: chart, + Chart: appMeshController, AppVersion: version, }, Namespace: namespace, @@ -70,7 +76,40 @@ func (appMesh *AppMesh) applyHelmChart(del bool, version, namespace string) erro return ErrApplyHelmChart(err) } - return nil + // Install appmesh-gateway + err = kClient.ApplyHelmChart(mesherykube.ApplyHelmChartConfig{ + ChartLocation: mesherykube.HelmChartLocation{ + Repository: repo, + Chart: appMeshGateway, + AppVersion: version, + }, + Namespace: namespace, + Action: act, + CreateNamespace: true, + }) + if err != nil { + return ErrApplyHelmChart(err) + } + + // Install appmesh-injector. Only needed for controller versions older + // than 1.0.0 + if controlPlaneVersion, err := strconv.Atoi(strings.TrimPrefix(version, "v")); controlPlaneVersion < 1 && err != nil { + err = kClient.ApplyHelmChart(mesherykube.ApplyHelmChartConfig{ + ChartLocation: mesherykube.HelmChartLocation{ + Repository: repo, + Chart: appMeshInject, + AppVersion: version, + }, + Namespace: namespace, + Action: act, + CreateNamespace: true, + }) + if err != nil { + return ErrApplyHelmChart(err) + } + } + + return err } func (appMesh *AppMesh) applyManifest(manifest []byte, isDel bool, namespace string) error { From da6f187f678670c3c0751aafe59124ffce7779b8 Mon Sep 17 00:00:00 2001 From: Rudraksh Pareek Date: Thu, 21 Oct 2021 00:22:39 +0530 Subject: [PATCH 2/2] gateway is not a base install component Signed-off-by: Rudraksh Pareek --- appmesh/install.go | 15 --------------- 1 file changed, 15 deletions(-) diff --git a/appmesh/install.go b/appmesh/install.go index b09a02d..f3deb81 100644 --- a/appmesh/install.go +++ b/appmesh/install.go @@ -76,21 +76,6 @@ func (appMesh *AppMesh) applyHelmChart(del bool, version, namespace string) erro return ErrApplyHelmChart(err) } - // Install appmesh-gateway - err = kClient.ApplyHelmChart(mesherykube.ApplyHelmChartConfig{ - ChartLocation: mesherykube.HelmChartLocation{ - Repository: repo, - Chart: appMeshGateway, - AppVersion: version, - }, - Namespace: namespace, - Action: act, - CreateNamespace: true, - }) - if err != nil { - return ErrApplyHelmChart(err) - } - // Install appmesh-injector. Only needed for controller versions older // than 1.0.0 if controlPlaneVersion, err := strconv.Atoi(strings.TrimPrefix(version, "v")); controlPlaneVersion < 1 && err != nil {