diff --git a/Dockerfile b/Dockerfile index 799589dc3..c4bf9c365 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,16 +4,15 @@ WORKDIR /github.com/layer5io/meshery-istio ADD . . RUN GOPROXY=direct GOSUMDB=off go build -ldflags="-w -s" -a -o /meshery-istio . RUN find . -name "*.go" -type f -delete; mv istio / -RUN wget -O /istio.tar.gz https://github.com/istio/istio/releases/download/1.7.3/istio-1.7.3-linux-amd64.tar.gz +RUN wget -O /istio.tar.gz https://github.com/istio/istio/releases/download/1.5.1/istio-1.5.1-linux.tar.gz FROM alpine -RUN apk --update add ca-certificates -RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 +RUN apk --update add ca-certificates curl +# RUN mkdir /lib64 && ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2 COPY --from=bd /meshery-istio /app/ COPY --from=bd /istio /app/istio COPY --from=bd /istio.tar.gz /app/ -COPY --from=bd /etc/passwd /etc/passwd -ENV ISTIO_VERSION=istio-1.7.3 -USER appuser +COPY --from=bd //github.com/layer5io/meshery-istio/scripts /app/scripts/. +ENV ISTIO_VERSION=istio-1.5.1 WORKDIR /app CMD ./meshery-istio diff --git a/istio/install-istio.go b/istio/install-istio.go index faf6e7768..5458b139b 100644 --- a/istio/install-istio.go +++ b/istio/install-istio.go @@ -3,40 +3,47 @@ package istio import ( "archive/tar" "compress/gzip" + "context" "encoding/json" "fmt" "io" "io/ioutil" "net/http" "os" + "os/exec" "path" "path/filepath" "regexp" "strings" "time" + "github.com/layer5io/meshery-istio/meshes" "github.com/pkg/errors" "github.com/sirupsen/logrus" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) const ( repoURL = "https://api.github.com/repos/istio/istio/releases/latest" - urlSuffix = "-linux.tar.gz" + urlSuffix = "-osx.tar.gz" crdPattern = "crd(.*)yaml" cachePeriod = 6 * time.Hour ) var ( - localByPassFile = "/app/istio.tar.gz" + localByPassFile = "/tmp/istio.tar.gz" - localFile = path.Join(os.TempDir(), "istio.tar.gz") - destinationFolder = path.Join(os.TempDir(), "istio") - basePath = path.Join(destinationFolder, "%s") - installWithmTLSFile = path.Join(basePath, "install/kubernetes/istio-demo.yaml") - bookInfoInstallFile = path.Join(basePath, "samples/bookinfo/platform/kube/bookinfo.yaml") - bookInfoGatewayInstallFile = path.Join(basePath, "samples/bookinfo/networking/bookinfo-gateway.yaml") - crdFolder = path.Join(basePath, "install/kubernetes/helm/istio-init/files/") + localFile = path.Join(os.TempDir(), "istio.tar.gz") + destinationFolder = path.Join(os.TempDir(), "istio") + basePath = path.Join(destinationFolder, "%s") + installWithmTLSFile = path.Join(basePath, "install/kubernetes/istio-demo.yaml") + crdFolder = path.Join(basePath, "install/kubernetes/helm/istio-init/files/") + httpbinInstallFile = path.Join(basePath, "samples/httpbin/httpbin.yaml") + httpbinGatewayInstallFile = path.Join(basePath, "samples/httpbin/httpbin-gateway.yaml") + + bookInfoGatewayInstallFile = path.Join(basePath, "samples/bookinfo/networking/bookinfo-gateway.yaml") + bookInfoInstallFile = path.Join(basePath, "samples/bookinfo/platform/kube/bookinfo.yaml") defaultBookInfoDestRulesFile = path.Join(basePath, "samples/bookinfo/networking/destination-rule-all-mtls.yaml") bookInfoRouteToV1AllServicesFile = path.Join(basePath, "samples/bookinfo/networking/virtual-service-all-v1.yaml") bookInfoRouteToReviewsV2ForJasonFile = path.Join(basePath, "samples/bookinfo/networking/virtual-service-reviews-test-v2.yaml") @@ -58,6 +65,73 @@ type asset struct { DownloadURL string `json:"browser_download_url,omitempty"` } +func (iClient *Client) AddLabel(namespace string, remove bool) error { + ns, err := iClient.k8sClientset.CoreV1().Namespaces().Get(context.TODO(), namespace, metav1.GetOptions{}) + if err != nil { + err = errors.Wrapf(err, "Unable to get namespace") + return err + } + + if ns.ObjectMeta.Labels == nil { + ns.ObjectMeta.Labels = map[string]string{} + } + ns.ObjectMeta.Labels["istio-injection"] = "enabled" + + if remove { + delete(ns.ObjectMeta.Labels, "istio-injection") + } + + _, err = iClient.k8sClientset.CoreV1().Namespaces().Update(context.TODO(), ns, metav1.UpdateOptions{}) + if err != nil { + err = errors.Wrapf(err, "Unable to update namespace with Label") + return err + } + return nil +} + +func (iClient *Client) executev173Install(ctx context.Context, arReq *meshes.ApplyRuleRequest) error { + Executable, err := exec.LookPath("./scripts/install.sh") + if err != nil { + return err + } + + if arReq.DeleteOp { + Executable, err = exec.LookPath("./scripts/delete.sh") + if err != nil { + return err + } + } + + cmd := &exec.Cmd{ + Path: Executable, + Args: []string{Executable}, + Stdout: os.Stdout, + Stderr: os.Stdout, + } + + mode := "istioctl" + if arReq.OpName == installOperatorIstioCommand { + mode = "operator" + } + + cmd.Env = append(os.Environ(), + "ISTIO_VERSION=1.7.3", + fmt.Sprintf("ISTIO_MODE=%s", mode), + "ISTIO_PROFILE=demo", + ) + + err = cmd.Start() + if err != nil { + return err + } + err = cmd.Wait() + if err != nil { + return err + } + + return nil +} + func (iClient *Client) getLatestReleaseURL() error { if iClient.istioReleaseDownloadURL == "" || time.Since(iClient.istioReleaseUpdatedAt) > cachePeriod { logrus.Debugf("API info url: %s", repoURL) @@ -331,6 +405,14 @@ func (iClient *Client) getBookInfoGatewayYAML() (string, error) { return iClient.getIstioComponentYAML(bookInfoGatewayInstallFile) } +func (iClient *Client) getHttpbinAppYAML() (string, error) { + return iClient.getIstioComponentYAML(httpbinInstallFile) +} + +func (iClient *Client) getHttpbinGatewayYAML() (string, error) { + return iClient.getIstioComponentYAML(httpbinGatewayInstallFile) +} + func (iClient *Client) getBookInfoDefaultDesinationRulesYAML() (string, error) { return iClient.getIstioComponentYAML(defaultBookInfoDestRulesFile) } diff --git a/istio/istio.go b/istio/istio.go index 49d381f54..afa76af36 100644 --- a/istio/istio.go +++ b/istio/istio.go @@ -31,6 +31,7 @@ import ( "github.com/layer5io/meshery-istio/meshes" "github.com/pkg/errors" "github.com/sirupsen/logrus" + kubeerror "k8s.io/apimachinery/pkg/api/errors" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/apis/meta/v1/unstructured" "k8s.io/apimachinery/pkg/runtime" @@ -38,6 +39,7 @@ import ( ) const ( + httpbinv2name = "httpbinv2" hipsterShopIstioManifestsURL = "https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/master/release/istio-manifests.yaml" hipsterShopKubernetesManifestsURL = "https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/master/release/kubernetes-manifests.yaml" ) @@ -68,19 +70,10 @@ func (iClient *Client) CreateMeshInstance(_ context.Context, k8sReq *meshes.Crea func (iClient *Client) createResource(ctx context.Context, res schema.GroupVersionResource, data *unstructured.Unstructured) error { _, err := iClient.k8sDynamicClient.Resource(res).Namespace(data.GetNamespace()).Create(context.TODO(), data, metav1.CreateOptions{}) - if err != nil { - if strings.Contains(err.Error(), "already exists") { - // if err1 := iClient.deleteResource(ctx, res, data); err1 != nil { - - // } - return errors.Wrap(err, "resource already exists") - } + if err != nil && !kubeerror.IsAlreadyExists(err) { err = errors.Wrapf(err, "unable to create the requested resource, attempting operation without namespace") logrus.Warn(err) - if _, err = iClient.k8sDynamicClient.Resource(res).Create(context.TODO(), data, metav1.CreateOptions{}); err != nil { - if strings.Contains(err.Error(), "already exists") { - return errors.Wrap(err, "resource already exists") - } + if _, err = iClient.k8sDynamicClient.Resource(res).Create(context.TODO(), data, metav1.CreateOptions{}); err != nil && !kubeerror.IsAlreadyExists(err) { err = errors.Wrapf(err, "unable to create the requested resource, attempting to update") logrus.Error(err) return err @@ -117,8 +110,7 @@ func (iClient *Client) deleteResource(ctx context.Context, res schema.GroupVersi err := iClient.k8sDynamicClient.Resource(res).Namespace(data.GetNamespace()).Delete(context.TODO(), data.GetName(), metav1.DeleteOptions{}) if err != nil { err = errors.Wrapf(err, "unable to delete the requested resource, attempting operation without namespace") - logrus.Warn(err) - + logrus.Error(err) err := iClient.k8sDynamicClient.Resource(res).Delete(context.TODO(), data.GetName(), metav1.DeleteOptions{}) if err != nil { err = errors.Wrapf(err, "unable to delete the requested resource") @@ -228,7 +220,7 @@ func (iClient *Client) executeRule(ctx context.Context, data *unstructured.Unstr case "logentry": kind = "logentries" case "kubernetes": - kind = "kuberneteses" + kind = "kubernetes" case "podsecuritypolicy": kind = "podsecuritypolicies" case "serviceentry": @@ -403,6 +395,62 @@ func (iClient *Client) executeInstall(ctx context.Context, arReq *meshes.ApplyRu return nil } +func (iClient *Client) executeHttpbinInstall(ctx context.Context, arReq *meshes.ApplyRuleRequest, version string) error { + if version == "v2" { + if arReq.DeleteOp { + err := iClient.k8sClientset.AppsV1().Deployments(arReq.Namespace).Delete(context.TODO(), httpbinv2name, metav1.DeleteOptions{}) + if err != nil { + err = errors.Wrapf(err, "Unable to delete deployment httpbin v2") + logrus.Error(err) + return err + } + } + + deploy, err := iClient.k8sClientset.AppsV1().Deployments(arReq.Namespace).Get(context.TODO(), "httpbin", metav1.GetOptions{}) + if err != nil { + err = errors.Wrapf(err, "Unable to get deployment httpbin") + logrus.Error(err) + return err + } + + if deploy.ObjectMeta.Labels == nil { + deploy.ObjectMeta.Labels = map[string]string{} + } + deploy.ObjectMeta.Labels["version"] = "v2" + deploy.ObjectMeta.Name = httpbinv2name + deploy.ObjectMeta.ResourceVersion = "" + + _, err = iClient.k8sClientset.AppsV1().Deployments(arReq.Namespace).Create(context.TODO(), deploy, metav1.CreateOptions{}) + if err != nil && !kubeerror.IsAlreadyExists(err) { + err = errors.Wrapf(err, "Unable to create deployment httpbin version 2") + logrus.Error(err) + return err + } + return nil + } + + if !arReq.DeleteOp { + if err := iClient.labelNamespaceForAutoInjection(ctx, arReq.Namespace); err != nil { + return err + } + } + yamlFileContents, err := iClient.getHttpbinAppYAML() + if err != nil { + return err + } + if err := iClient.applyConfigChange(ctx, yamlFileContents, arReq.Namespace, arReq.DeleteOp, false); err != nil { + return err + } + yamlFileContents, err = iClient.getHttpbinGatewayYAML() + if err != nil { + return err + } + if err := iClient.applyConfigChange(ctx, yamlFileContents, arReq.Namespace, arReq.DeleteOp, false); err != nil { + return err + } + return nil +} + func (iClient *Client) executeBookInfoInstall(ctx context.Context, arReq *meshes.ApplyRuleRequest) error { if !arReq.DeleteOp { if err := iClient.labelNamespaceForAutoInjection(ctx, arReq.Namespace); err != nil { @@ -496,6 +544,35 @@ func (iClient *Client) ApplyOperation(ctx context.Context, arReq *meshes.ApplyRu isCustomOp := false switch arReq.OpName { + case installv173IstioCommand, installOperatorIstioCommand: + go func() { + opName1 := "deploying" + if arReq.DeleteOp { + opName1 = "removing" + } + if err := iClient.executev173Install(ctx, arReq); err != nil { + iClient.eventChan <- &meshes.EventsResponse{ + OperationId: arReq.OperationId, + EventType: meshes.EventType_ERROR, + Summary: fmt.Sprintf("Error while %s Istio", opName1), + Details: err.Error(), + } + return + } + opName := "deployed" + if arReq.DeleteOp { + opName = "removed" + } + iClient.eventChan <- &meshes.EventsResponse{ + OperationId: arReq.OperationId, + EventType: meshes.EventType_INFO, + Summary: fmt.Sprintf("Istio %s successfully", opName), + Details: fmt.Sprintf("The latest version of Istio is now %s.", opName), + } + }() + return &meshes.ApplyRuleResponse{ + OperationId: arReq.OperationId, + }, nil case installmTLSIstioCommand: go func() { opName1 := "deploying" @@ -557,6 +634,35 @@ func (iClient *Client) ApplyOperation(ctx context.Context, arReq *meshes.ApplyRu OperationId: arReq.OperationId, }, nil + case installHttpbinCommandV1, installHttpbinCommandV2: + go func() { + opName1 := "deploying" + if arReq.DeleteOp { + opName1 = "removing" + } + if err := iClient.executeHttpbinInstall(ctx, arReq, op.templateName); err != nil { + iClient.eventChan <- &meshes.EventsResponse{ + OperationId: arReq.OperationId, + EventType: meshes.EventType_ERROR, + Summary: fmt.Sprintf("Error while %s the canonical Httpbin App", opName1), + Details: err.Error(), + } + return + } + opName := "deployed" + if arReq.DeleteOp { + opName = "removed" + } + iClient.eventChan <- &meshes.EventsResponse{ + OperationId: arReq.OperationId, + EventType: meshes.EventType_INFO, + Summary: fmt.Sprintf("Httpbin app %s successfully", opName), + Details: fmt.Sprintf("The Istio canonical Httpbin app is now %s.", opName), + } + }() + return &meshes.ApplyRuleResponse{ + OperationId: arReq.OperationId, + }, nil case installBookInfoCommand: go func() { opName1 := "deploying" @@ -673,16 +779,16 @@ func (iClient *Client) ApplyOperation(ctx context.Context, arReq *meshes.ApplyRu } return } - opName := "deployed" - if arReq.DeleteOp { - opName = "removed" - } - iClient.eventChan <- &meshes.EventsResponse{ - OperationId: arReq.OperationId, - EventType: meshes.EventType_INFO, - Summary: fmt.Sprintf("\"%s\" %s successfully", op.name, opName), - Details: fmt.Sprintf("\"%s\" %s successfully", op.name, opName), - } + // opName := "deployed" + // if arReq.DeleteOp { + // opName = "removed" + // } + // iClient.eventChan <- &meshes.EventsResponse{ + // OperationId: arReq.OperationId, + // EventType: meshes.EventType_INFO, + // Summary: fmt.Sprintf("\"%s\" %s successfully", op.name, opName), + // Details: fmt.Sprintf("\"%s\" %s successfully", op.name, opName), + // } }() return &meshes.ApplyRuleResponse{ @@ -700,20 +806,15 @@ func (iClient *Client) applyConfigChange(ctx context.Context, yamlFileContents, } for _, yml := range yamls { if strings.TrimSpace(yml) != "" { - if err := iClient.applyRulePayload(ctx, namespace, []byte(yml), delete, isCustomOp); err != nil { - errStr := strings.TrimSpace(err.Error()) - if delete { - if strings.HasSuffix(errStr, "not found") || - strings.HasSuffix(errStr, "the server could not find the requested resource") { - // logrus.Debugf("skipping error. . .") - continue - } - } else { - if strings.HasSuffix(errStr, "already exists") { - continue - } - } - // logrus.Debugf("returning error: %v", err) + err := iClient.applyRulePayload(ctx, namespace, []byte(yml), delete, isCustomOp) + if err != nil && !kubeerror.IsAlreadyExists(err) { + err = errors.Wrap(err, "error while applying rule payload yaml") + logrus.Error(err) + return err + } + if delete && !kubeerror.IsNotFound(err) && !kubeerror.IsInvalid(err) && !kubeerror.IsGone(err) && !kubeerror.IsResourceExpired(err) { + err = errors.Wrap(err, "error while deleting rule payload yaml") + logrus.Error(err) return err } } diff --git a/istio/supported_ops.go b/istio/supported_ops.go index 13d7b47c1..76d3bcd17 100644 --- a/istio/supported_ops.go +++ b/istio/supported_ops.go @@ -25,13 +25,21 @@ type supportedOperation struct { } const ( - customOpCommand = "custom" - runVet = "istio_vet" - installmTLSIstioCommand = "istio_mtls_install" + customOpCommand = "custom" + runVet = "istio_vet" + + // Install istio + installv173IstioCommand = "istio_install_v173" + installv173IstioCommandTls = "istio_install_v173_tls" + installOperatorIstioCommand = "istio_install_operator" + installmTLSIstioCommand = "istio_mtls_install" + verifyInstallation = "verify_installation" // requires + installAddons = "install_addons" + injectLabels = "inject_labels" + + // Bookinfo installBookInfoCommand = "install_book_info" cbCommand = "cb1" - installSMI = "install_smi" - installHTTPBin = "install_http_bin" googleMSSampleApplication = "google_microservices_demo_application" bookInfoDefaultDestinationRules = "bookInfoDefaultDestinationRules" bookInfoRouteToV1AllServices = "bookInfoRouteToV1AllServices" @@ -41,12 +49,52 @@ const ( bookInfoInjectDelayForRatingsForJason = "bookInfoInjectDelayForRatingsForJason" bookInfoInjectHTTPAbortToRatingsForJason = "bookInfoInjectHTTPAbortToRatingsForJason" bookInfoProductPageCircuitBreaking = "bookInfoProductPageCircuitBreaking" - smiConformanceCommand = "smiConformanceTest" + + // HTTPbin + installHttpbinCommandV1 = "install_http_binv1" + installHttpbinCommandV2 = "install_http_binv2" + + // Labs + enablePrometheus = "enable_prometheus" + enableGrafana = "enable_grafana" + enableKiali = "enable_kiali" + denyAllPolicy = "deny_all_policy" + strictMtls = "strict_mtls" + mutualMtls = "mutual_mtls" + disableMtls = "disable_mtls" + + bookInfoRouteV1ForUser = "bookinfo_route_v1_for_user" + bookInfoMirrorTrafficToV2 = "bookinfo_mirror_traffic_to_v2" + bookInfoRetrySpecForReviews = "bookinfo_retry_spec_for_reviews" + bookInfoCanaryDeploy20V3 = "bookinfo_canary_deploy_20_v3" + bookInfoCanaryDeploy80V3 = "bookinfo_canary_deploy_80_v3" + bookInfoCanaryDeploy100V3 = "bookinfo_canary_deploy_100_v3" + bookInfoInjectDelayFaultRatings = "bookinfo_inject_delay_fault_ratings" + bookInfoInjectDelayFaultReviews = "bookinfo_inject_delay_fault_reviews" + bookInfoConfigureConnectionPoolOutlier = "bookinfo_configure_connection_pool_outlier" + bookInfoAllowGet = "bookinfo_allow_get" + bookInfoAllowReviewsForUser = "bookinfo_allow_reviews_for_user" + + // SMI conformance test + smiConformanceCommand = "smiConformanceTest" + installSMI = "install_smi" ) var supportedOps = map[string]supportedOperation{ + installv173IstioCommand: { + name: "Istio 1.7.3", + opType: meshes.OpCategory_INSTALL, + }, + installv173IstioCommandTls: { + name: "Istio 1.7.3 with mTLS", + opType: meshes.OpCategory_INSTALL, + }, + installOperatorIstioCommand: { + name: "Istio with Operator", + opType: meshes.OpCategory_INSTALL, + }, installmTLSIstioCommand: { - name: "Latest Istio with mTLS", + name: "Istio 1.5.1 with mTLS", opType: meshes.OpCategory_INSTALL, }, installBookInfoCommand: { @@ -71,31 +119,31 @@ var supportedOps = map[string]supportedOperation{ opType: meshes.OpCategory_CONFIGURE, }, bookInfoRouteToV1AllServices: { - name: "BookInfo: Route traffic to V1 of all BookInfo services", + name: "BookInfo: Route traffic to v1 of all BookInfo services", opType: meshes.OpCategory_CONFIGURE, }, bookInfoRouteToReviewsV2ForJason: { - name: "BookInfo: Route traffic to V2 of BookInfo reviews service for user Jason", + name: "BookInfo: Route traffic to Reviews v2 for user Jason", opType: meshes.OpCategory_CONFIGURE, }, bookInfoCanary50pcReviewsV3: { - name: "BookInfo: Route 50% of the traffic to BookInfo reviews V3", + name: "BookInfo: Route 50% of the traffic to Reviews v3", opType: meshes.OpCategory_CONFIGURE, }, bookInfoCanary100pcReviewsV3: { - name: "BookInfo: Route 100% of the traffic to BookInfo reviews V3", + name: "BookInfo: Route 100% of the traffic to Reviews v3", opType: meshes.OpCategory_CONFIGURE, }, bookInfoInjectDelayForRatingsForJason: { - name: "BookInfo: Inject a 7s delay in the traffic to BookInfo ratings service for user Jason", + name: "BookInfo: Inject a 7s delay in the traffic to Ratings for user Jason", opType: meshes.OpCategory_CONFIGURE, }, bookInfoInjectHTTPAbortToRatingsForJason: { - name: "BookInfo: Inject HTTP abort to BookInfo ratings service for user Jason", + name: "BookInfo: Inject HTTP abort to Ratings for user Jason", opType: meshes.OpCategory_CONFIGURE, }, bookInfoProductPageCircuitBreaking: { - name: "BookInfo: Configure circuit breaking with max 1 request per connection and max 1 pending request to BookInfo productpage service", + name: "BookInfo: Configure circuit breaking with max 1 request per connection and max 1 pending request to Productpage service", opType: meshes.OpCategory_CONFIGURE, templateName: "book_info_product_page_circuit_breaking.tmpl", }, @@ -103,9 +151,14 @@ var supportedOps = map[string]supportedOperation{ name: "Service Mesh Interface (SMI) Istio Adapter", opType: meshes.OpCategory_INSTALL, }, - installHTTPBin: { - name: "httpbin Application", - templateName: "httpbin.yaml", + installHttpbinCommandV1: { + name: "httpbin Application V1", + templateName: "v1", + opType: meshes.OpCategory_SAMPLE_APPLICATION, + }, + installHttpbinCommandV2: { + name: "httpbin Application V2 (Needs V1 installed)", + templateName: "v2", opType: meshes.OpCategory_SAMPLE_APPLICATION, }, customOpCommand: { @@ -120,4 +173,76 @@ var supportedOps = map[string]supportedOperation{ name: "Run SMI conformance test", opType: meshes.OpCategory_VALIDATE, }, + enablePrometheus: { + name: "Enable Prometheus add-on", + opType: meshes.OpCategory_INSTALL, + }, + enableGrafana: { + name: "Enable Grafana add-on", + opType: meshes.OpCategory_INSTALL, + }, + enableKiali: { + name: "Enable Kiali add-on", + opType: meshes.OpCategory_INSTALL, + }, + denyAllPolicy: { + name: "Deny-all policy on the namespace", + opType: meshes.OpCategory_CONFIGURE, + }, + strictMtls: { + name: "Strict mTLS policy", + opType: meshes.OpCategory_CONFIGURE, + }, + mutualMtls: { + name: "Mutual mTLS policy", + opType: meshes.OpCategory_CONFIGURE, + }, + disableMtls: { + name: "Disable mTLS policy", + opType: meshes.OpCategory_CONFIGURE, + }, + bookInfoRouteV1ForUser: { + name: "BookInfo: Productpage to version v1", + opType: meshes.OpCategory_CONFIGURE, + }, + bookInfoMirrorTrafficToV2: { + name: "BookInfo: Productpage mirror traffic from v1 to v2", + opType: meshes.OpCategory_CONFIGURE, + }, + bookInfoRetrySpecForReviews: { + name: "BookInfo: Productpage to retry for Reviews application", + opType: meshes.OpCategory_CONFIGURE, + }, + bookInfoCanaryDeploy20V3: { + name: "BookInfo: Forward 20 percent traffic to Reviews v2", + opType: meshes.OpCategory_CONFIGURE, + }, + bookInfoCanaryDeploy80V3: { + name: "BookInfo: Forward 80 percent traffic to Reviews v2", + opType: meshes.OpCategory_CONFIGURE, + }, + bookInfoCanaryDeploy100V3: { + name: "BookInfo: Forward 100 percent traffic to Reviews v2", + opType: meshes.OpCategory_CONFIGURE, + }, + bookInfoInjectDelayFaultRatings: { + name: "BookInfo: Add delay to Ratings", + opType: meshes.OpCategory_CONFIGURE, + }, + bookInfoInjectDelayFaultReviews: { + name: "BookInfo: Add delay in Ratings", + opType: meshes.OpCategory_CONFIGURE, + }, + bookInfoConfigureConnectionPoolOutlier: { + name: "BookInfo: Connection pool limits and outlier detection", + opType: meshes.OpCategory_CONFIGURE, + }, + bookInfoAllowGet: { + name: "BookInfo: Allow only GET requests", + opType: meshes.OpCategory_CONFIGURE, + }, + bookInfoAllowReviewsForUser: { + name: "BookInfo: Allow Reviews only for user", + opType: meshes.OpCategory_CONFIGURE, + }, } diff --git a/scripts/delete.sh b/scripts/delete.sh new file mode 100755 index 000000000..d7885094a --- /dev/null +++ b/scripts/delete.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +if ! /tmp/istio/bin/istioctl x uninstall --purge -y; then + exit 1 +fi diff --git a/scripts/deleteHttpbin.sh b/scripts/deleteHttpbin.sh new file mode 100644 index 000000000..c5ac1e3a3 --- /dev/null +++ b/scripts/deleteHttpbin.sh @@ -0,0 +1,7 @@ +#!/bin/sh + +set -e + +if ! kubectl delete -f /tmp/istio/samples/httpbin/httpbin.yaml; then + exit 1 +fi diff --git a/scripts/install.sh b/scripts/install.sh new file mode 100755 index 000000000..3de2a864b --- /dev/null +++ b/scripts/install.sh @@ -0,0 +1,52 @@ +#!/bin/sh + +set -e + +: "${ISTIO_VERSION:=}" +: "${ARCH:=amd64}" +: "${DISTRO:=linux}" + +OS=`uname -s` +if [ "$OS" = "Linux" ]; then + DISTRO="linux" + URL="https://github.com/istio/istio/releases/download/$ISTIO_VERSION/istio-$ISTIO_VERSION-$DISTRO-$ARCH.tar.gz" +elif [ "$OS" = "Darwin" ]; then + DISTRO="osx" + URL="https://github.com/istio/istio/releases/download/$ISTIO_VERSION/istio-$ISTIO_VERSION-$DISTRO.tar.gz" +else + exit 1 +fi + +if [ -z "$DISTRO" ]; then + exit 2 +fi + + +if ! type "grep" > /dev/null 2>&1; then + exit 3; +fi +if ! type "curl" > /dev/null 2>&1; then + exit 4; +fi +if ! type "tar" > /dev/null 2>&1; then + exit 5; +fi +if ! type "gzip" > /dev/null 2>&1; then + exit 6; +fi + +if ! curl -s --head $URL | head -n 1 | grep "HTTP/1.[01] [23].." > /dev/null; then + exit 7 +fi + +if ! curl -L "$URL" | tar xz; then + exit 8 +fi + +if ! ./istio-$ISTIO_VERSION/bin/istioctl install --set profile=$ISTIO_PROFILE --set meshConfig.accessLogFile=/dev/stdout; then + exit 9 +fi + +mv istio-$ISTIO_VERSION /tmp/istio + +