diff --git a/Dockerfile b/Dockerfile index 0665079..ea9de6c 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,19 +1,19 @@ FROM golang:1.13.1 as bd RUN adduser --disabled-login --gecos "" appuser -WORKDIR /github.com/layer5io/meshery-istio +WORKDIR /github.com/layer5io/meshery-nsx-sm 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.3.0/istio-1.3.0-linux.tar.gz +RUN GOPROXY=direct GOSUMDB=off go build -ldflags="-w -s" -a -o /meshery-nsx-sm . +RUN find . -name "*.go" -type f -delete; mv nsx-sm / +RUN wget -O /nsx-sm.tar.gz https://github.com/nsx-sm/nsx-sm/releases/download/1.3.0/nsx-sm-1.3.0-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 -COPY --from=bd /meshery-istio /app/ -COPY --from=bd /istio /app/istio -COPY --from=bd /istio.tar.gz /app/ +COPY --from=bd /meshery-nsx-sm /app/ +COPY --from=bd /nsx-sm /app/nsx-sm +COPY --from=bd /nsx-sm.tar.gz /app/ COPY --from=bd /etc/passwd /etc/passwd -ENV ISTIO_VERSION=istio-1.3.0 +ENV nsx-sm_VERSION=nsx-sm-1.3.0 USER appuser WORKDIR /app -CMD ./meshery-istio +CMD ./meshery-nsx-sm diff --git a/README.md b/README.md index 29d34a9..3a9618f 100644 --- a/README.md +++ b/README.md @@ -1,10 +1,10 @@



-[![Docker Pulls](https://img.shields.io/docker/pulls/layer5/meshery-istio.svg)](https://hub.docker.com/r/layer5/meshery-istio) -[![Go Report Card](https://goreportcard.com/badge/github.com/layer5io/meshery-istio)](https://goreportcard.com/report/github.com/layer5io/meshery-istio) -[![Build Status](https://github.com/layer5io/meshery-istio/workflows/Meshery-Istio/badge.svg)](https://github.com/layer5io/meshery-istio/actions) -[![GitHub](https://img.shields.io/github/license/layer5io/meshery-istio.svg)](LICENSE) -[![GitHub issues by-label](https://img.shields.io/github/issues/layer5io/meshery-istio/help%20wanted.svg)](https://github.com/layer5io/meshery-istio/issues?q=is%3Aopen+is%3Aissue+label%3A"help+wanted") +[![Docker Pulls](https://img.shields.io/docker/pulls/layer5/meshery-nsx-sm.svg)](https://hub.docker.com/r/layer5/meshery-nsx-sm) +[![Go Report Card](https://goreportcard.com/badge/github.com/layer5io/meshery-nsx-sm)](https://goreportcard.com/report/github.com/layer5io/meshery-nsx-sm) +[![Build Status](https://github.com/layer5io/meshery-nsx-sm/workflows/Meshery-NSX-SM/badge.svg)](https://github.com/layer5io/meshery-nsx-sm/actions) +[![GitHub](https://img.shields.io/github/license/layer5io/meshery-nsx-sm.svg)](LICENSE) +[![GitHub issues by-label](https://img.shields.io/github/issues/layer5io/meshery-nsx-sm/help%20wanted.svg)](https://github.com/layer5io/meshery-nsx-sm/issues?q=is%3Aopen+is%3Aissue+label%3A"help+wanted") [![Website](https://img.shields.io/website/https/layer5.io/meshery.svg)](https://layer5.io/meshery/) [![Twitter Follow](https://img.shields.io/twitter/follow/layer5.svg?label=Follow&style=social)](https://twitter.com/intent/follow?screen_name=mesheryio) [![Slack](http://slack.layer5.io/badge.svg)](http://slack.layer5.io) diff --git a/go.mod b/go.mod index 4f80b7d..4b92f4b 100644 --- a/go.mod +++ b/go.mod @@ -1,11 +1,11 @@ -module github.com/layer5io/meshery-istio +module github.com/layer5io/meshery-nsx-sm go 1.13 require ( github.com/Azure/go-autorest/autorest/adal v0.6.0 // indirect - github.com/aspenmesh/istio-client-go v0.0.0-20190426173040-3e73c27b9ace - github.com/aspenmesh/istio-vet v0.0.0-20190708155745-fac74e54e2e6 + github.com/aspenmesh/nsx-sm-client-go v0.0.0-20190426173040-3e73c27b9ace + github.com/aspenmesh/nsx-sm-vet v0.0.0-20190708155745-fac74e54e2e6 github.com/cnf/structhash v0.0.0-20180104161610-62a607eb0224 // indirect github.com/ghodss/yaml v1.0.0 github.com/gogo/protobuf v1.3.0 // indirect @@ -27,7 +27,7 @@ require ( golang.org/x/tools v0.0.0-20191005014404-c9f9432ec4b2 // indirect google.golang.org/grpc v1.23.0 gopkg.in/inf.v0 v0.9.1 // indirect - istio.io/api v0.0.0-20190905172106-906cbe6415a5 // indirect + nsx-sm.io/api v0.0.0-20190905172106-906cbe6415a5 // indirect k8s.io/api v0.0.0-20190313235455-40a48860b5ab // indirect k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1 k8s.io/client-go v11.0.0+incompatible diff --git a/go.sum b/go.sum index 7c22f0f..f7e91fa 100644 --- a/go.sum +++ b/go.sum @@ -18,10 +18,10 @@ github.com/Azure/go-autorest/logger v0.1.0/go.mod h1:oExouG+K6PryycPJfVSxi/koC6L github.com/Azure/go-autorest/tracing v0.5.0 h1:TRn4WjSnkcSy5AEG3pnbtFSwNtwzjr4VYyQflFE619k= github.com/Azure/go-autorest/tracing v0.5.0/go.mod h1:r/s2XiOKccPW3HrqB+W0TQzfbtp2fGCgRFtBroKn4Dk= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/aspenmesh/istio-client-go v0.0.0-20190426173040-3e73c27b9ace h1:m+Xk2zXjEtnTGA4T3zb4+avMrIq6DBMqFJM3FcjGji0= -github.com/aspenmesh/istio-client-go v0.0.0-20190426173040-3e73c27b9ace/go.mod h1:HbtpC/r+MCS1vrS/OIs5vLVohdIh9KgX1utxg+fJ8WE= -github.com/aspenmesh/istio-vet v0.0.0-20190708155745-fac74e54e2e6 h1:kqFjAq0OKfwrqOASkZ3OhEQQGDUsFw5zwBEHsROGoNI= -github.com/aspenmesh/istio-vet v0.0.0-20190708155745-fac74e54e2e6/go.mod h1:8hVDM8l0fEURMlC806jrymafA2y9ty0tSmkx6KWuSSI= +github.com/aspenmesh/nsx-sm-client-go v0.0.0-20190426173040-3e73c27b9ace h1:m+Xk2zXjEtnTGA4T3zb4+avMrIq6DBMqFJM3FcjGji0= +github.com/aspenmesh/nsx-sm-client-go v0.0.0-20190426173040-3e73c27b9ace/go.mod h1:HbtpC/r+MCS1vrS/OIs5vLVohdIh9KgX1utxg+fJ8WE= +github.com/aspenmesh/nsx-sm-vet v0.0.0-20190708155745-fac74e54e2e6 h1:kqFjAq0OKfwrqOASkZ3OhEQQGDUsFw5zwBEHsROGoNI= +github.com/aspenmesh/nsx-sm-vet v0.0.0-20190708155745-fac74e54e2e6/go.mod h1:8hVDM8l0fEURMlC806jrymafA2y9ty0tSmkx6KWuSSI= github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= github.com/cnf/structhash v0.0.0-20180104161610-62a607eb0224 h1:rnCKRrdSBqc061l0CDuYB+7X3w6w8IK/VCSChJXv62g= github.com/cnf/structhash v0.0.0-20180104161610-62a607eb0224/go.mod h1:pCxVEbcm3AMg7ejXyorUXi6HQCzOIBf7zEDVPtw0/U4= @@ -66,6 +66,7 @@ github.com/modern-go/reflect2 v1.0.1 h1:9f412s+6RmYXLWZSEzVVgPGK7C2PphHj5RJrvfx9 github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/sirupsen/logrus v1.4.2 h1:SPIRibHv4MatM3XXNO2BJeFLZwZ2LvZgfQ5+UNI2im4= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= @@ -75,6 +76,7 @@ github.com/spf13/pflag v1.0.3/go.mod h1:DYY7MBk1bdzusC3SYhjObp+wFpr4gzcvqqNjLnIn github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= golang.org/x/crypto v0.0.0-20190211182817-74369b46fc67/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= @@ -127,9 +129,9 @@ gopkg.in/yaml.v2 v2.2.2 h1:ZCJp+EgiOT7lHqUV2J862kp8Qj64Jo6az82+3Td9dZw= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -istio.io/api v0.0.0-20190905172106-906cbe6415a5 h1:FEDTpBQs8Qs0Upw7WeOZjyylwxP6rWcUmm5dquy3Dmo= -istio.io/api v0.0.0-20190905172106-906cbe6415a5/go.mod h1:42cBjnu/rTJcCaKi8nLdIvq0n71RcLrkgZ9IQSvDdSQ= -istio.io/gogo-genproto v0.0.0-20190731221249-06e20ada0df2/go.mod h1:IjvrbUlRbbw4JCpsgvgihcz9USUwEoNTL/uwMtyV5yk= +nsx-sm.io/api v0.0.0-20190905172106-906cbe6415a5 h1:FEDTpBQs8Qs0Upw7WeOZjyylwxP6rWcUmm5dquy3Dmo= +nsx-sm.io/api v0.0.0-20190905172106-906cbe6415a5/go.mod h1:42cBjnu/rTJcCaKi8nLdIvq0n71RcLrkgZ9IQSvDdSQ= +nsx-sm.io/gogo-genproto v0.0.0-20190731221249-06e20ada0df2/go.mod h1:IjvrbUlRbbw4JCpsgvgihcz9USUwEoNTL/uwMtyV5yk= k8s.io/api v0.0.0-20190313235455-40a48860b5ab h1:DG9A67baNpoeweOy2spF1OWHhnVY5KR7/Ek/+U1lVZc= k8s.io/api v0.0.0-20190313235455-40a48860b5ab/go.mod h1:iuAfoD4hCxJ8Onx9kaTIt30j7jUFS00AXQi6QMi99vA= k8s.io/apimachinery v0.0.0-20190313205120-d7deff9243b1 h1:IS7K02iBkQXpCeieSiyJjGoLSdVOv2DbPaWHJ+ZtgKg= diff --git a/main.go b/main.go index 1affd20..d1ebcd3 100644 --- a/main.go +++ b/main.go @@ -25,8 +25,8 @@ import ( "github.com/sirupsen/logrus" - "github.com/layer5io/meshery-istio/istio" - mesh "github.com/layer5io/meshery-istio/meshes" + mesh "github.com/layer5io/meshery-nsx-sm/meshes" + "github.com/layer5io/meshery-nsx-sm/nsx-sm" ) var ( @@ -55,7 +55,7 @@ func main() { s := grpc.NewServer( // grpc.Creds(credentials.NewServerTLSFromCert(&insecure.Cert)), ) - mesh.RegisterMeshServiceServer(s, &istio.Client{}) + mesh.RegisterMeshServiceServer(s, &nsx-sm.Client{}) // Serve gRPC Server logrus.Infof("Serving gRPC on %s", addr) diff --git a/istio/client.go b/nsx-sm/client.go similarity index 93% rename from istio/client.go rename to nsx-sm/client.go index c39d92d..d60ef79 100644 --- a/istio/client.go +++ b/nsx-sm/client.go @@ -12,12 +12,12 @@ // See the License for the specific language governing permissions and // limitations under the License. -package istio +package nsx-sm import ( "time" - "github.com/layer5io/meshery-istio/meshes" + "github.com/layer5io/meshery-nsx-sm/meshes" "github.com/sirupsen/logrus" "k8s.io/client-go/dynamic" "k8s.io/client-go/kubernetes" @@ -30,16 +30,16 @@ import ( "github.com/ghodss/yaml" ) -// Client represents an Istio client in Meshery +// Client represents an nsx-sm client in Meshery type Client struct { config *rest.Config k8sClientset *kubernetes.Clientset k8sDynamicClient dynamic.Interface eventChan chan *meshes.EventsResponse - istioReleaseVersion string - istioReleaseDownloadURL string - istioReleaseUpdatedAt time.Time + nsx-smReleaseVersion string + nsx-smReleaseDownloadURL string + nsx-smReleaseUpdatedAt time.Time } func configClient(kubeconfig []byte, contextName string) (*rest.Config, error) { diff --git a/istio/config_templates/book_info_product_page_circuit_breaking.tmpl b/nsx-sm/config_templates/book_info_product_page_circuit_breaking.tmpl similarity index 86% rename from istio/config_templates/book_info_product_page_circuit_breaking.tmpl rename to nsx-sm/config_templates/book_info_product_page_circuit_breaking.tmpl index 3f19946..1f69b9d 100644 --- a/istio/config_templates/book_info_product_page_circuit_breaking.tmpl +++ b/nsx-sm/config_templates/book_info_product_page_circuit_breaking.tmpl @@ -1,4 +1,4 @@ -apiVersion: networking.istio.io/v1alpha3 +apiVersion: networking.nsx-sm.io/v1alpha3 kind: DestinationRule metadata: name: productpage @@ -10,7 +10,7 @@ spec: name: v1 trafficPolicy: tls: - mode: ISTIO_MUTUAL + mode: NSX-SM_MUTUAL connectionPool: tcp: maxConnections: 1 diff --git a/istio/config_templates/circuit_breaking.tmpl b/nsx-sm/config_templates/circuit_breaking.tmpl similarity index 84% rename from istio/config_templates/circuit_breaking.tmpl rename to nsx-sm/config_templates/circuit_breaking.tmpl index d527822..cf69549 100644 --- a/istio/config_templates/circuit_breaking.tmpl +++ b/nsx-sm/config_templates/circuit_breaking.tmpl @@ -1,4 +1,4 @@ -apiVersion: networking.istio.io/v1alpha3 +apiVersion: networking.nsx-sm.io/v1alpha3 kind: DestinationRule metadata: name: httpbin @@ -6,7 +6,7 @@ spec: host: httpbin trafficPolicy: tls: - mode: ISTIO_MUTUAL + mode: NSX-SM_MUTUAL connectionPool: tcp: maxConnections: 1 diff --git a/istio/config_templates/httpbin.yaml b/nsx-sm/config_templates/httpbin.yaml similarity index 89% rename from istio/config_templates/httpbin.yaml rename to nsx-sm/config_templates/httpbin.yaml index 05bb146..744668c 100644 --- a/istio/config_templates/httpbin.yaml +++ b/nsx-sm/config_templates/httpbin.yaml @@ -31,13 +31,13 @@ spec: ports: - containerPort: 80 --- -apiVersion: networking.istio.io/v1alpha3 +apiVersion: networking.nsx-sm.io/v1alpha3 kind: Gateway metadata: name: httpbin-gateway spec: selector: - istio: ingressgateway + nsx-sm: ingressgateway servers: - port: number: 80 @@ -46,7 +46,7 @@ spec: hosts: - "*" --- -apiVersion: networking.istio.io/v1alpha3 +apiVersion: networking.nsx-sm.io/v1alpha3 kind: VirtualService metadata: name: httpbin diff --git a/istio/config_templates/namespace.yml b/nsx-sm/config_templates/namespace.yml similarity index 100% rename from istio/config_templates/namespace.yml rename to nsx-sm/config_templates/namespace.yml diff --git a/istio/config_templates/smi/operator.yaml b/nsx-sm/config_templates/smi/operator.yaml similarity index 56% rename from istio/config_templates/smi/operator.yaml rename to nsx-sm/config_templates/smi/operator.yaml index 79c3e71..5ca38d4 100644 --- a/istio/config_templates/smi/operator.yaml +++ b/nsx-sm/config_templates/smi/operator.yaml @@ -1,26 +1,26 @@ apiVersion: apps/v1 kind: Deployment metadata: - name: smi-adapter-istio - namespace: istio-system + name: smi-adapter-nsx-sm + namespace: nsx-sm-system spec: replicas: 1 selector: matchLabels: - name: smi-adapter-istio + name: smi-adapter-nsx-sm template: metadata: labels: - name: smi-adapter-istio + name: smi-adapter-nsx-sm annotations: - sidecar.istio.io/inject: "false" + sidecar.nsx-sm.io/inject: "false" spec: - serviceAccountName: smi-adapter-istio + serviceAccountName: smi-adapter-nsx-sm containers: - - name: smi-adapter-istio - image: layer5/smi-istio:latest + - name: smi-adapter-nsx-sm + image: layer5/smi-nsx-sm:latest command: - - smi-adapter-istio + - smi-adapter-nsx-sm imagePullPolicy: Always env: - name: WATCH_NAMESPACE @@ -30,4 +30,4 @@ spec: fieldRef: fieldPath: metadata.name - name: OPERATOR_NAME - value: "smi-adapter-istio" + value: "smi-adapter-nsx-sm" diff --git a/istio/config_templates/smi/rbac.yaml b/nsx-sm/config_templates/smi/rbac.yaml similarity index 79% rename from istio/config_templates/smi/rbac.yaml rename to nsx-sm/config_templates/smi/rbac.yaml index 7adb042..6415206 100644 --- a/istio/config_templates/smi/rbac.yaml +++ b/nsx-sm/config_templates/smi/rbac.yaml @@ -1,14 +1,14 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: smi-adapter-istio - namespace: istio-system + name: smi-adapter-nsx-sm + namespace: nsx-sm-system --- apiVersion: rbac.authorization.k8s.io/v1 kind: ClusterRole metadata: - name: smi-adapter-istio - namespace: istio-system + name: smi-adapter-nsx-sm + namespace: nsx-sm-system rules: - apiGroups: - "" @@ -41,7 +41,7 @@ rules: - apiGroups: - apps resourceNames: - - smi-adapter-istio + - smi-adapter-nsx-sm resources: - deployments/finalizers verbs: @@ -53,7 +53,7 @@ rules: verbs: - '*' - apiGroups: - - networking.istio.io + - networking.nsx-sm.io resources: - '*' verbs: @@ -62,12 +62,12 @@ rules: kind: ClusterRoleBinding apiVersion: rbac.authorization.k8s.io/v1 metadata: - name: smi-adapter-istio + name: smi-adapter-nsx-sm subjects: - kind: ServiceAccount - name: smi-adapter-istio - namespace: istio-system + name: smi-adapter-nsx-sm + namespace: nsx-sm-system roleRef: kind: ClusterRole - name: smi-adapter-istio + name: smi-adapter-nsx-sm apiGroup: rbac.authorization.k8s.io \ No newline at end of file diff --git a/istio/config_templates/smi/split_v1alpha1_trafficsplit_crd.yaml b/nsx-sm/config_templates/smi/split_v1alpha1_trafficsplit_crd.yaml similarity index 100% rename from istio/config_templates/smi/split_v1alpha1_trafficsplit_crd.yaml rename to nsx-sm/config_templates/smi/split_v1alpha1_trafficsplit_crd.yaml diff --git a/istio/install-istio.go b/nsx-sm/install-nsx-sm.go similarity index 80% rename from istio/install-istio.go rename to nsx-sm/install-nsx-sm.go index 9c0a898..d0e9c37 100644 --- a/istio/install-istio.go +++ b/nsx-sm/install-nsx-sm.go @@ -1,4 +1,4 @@ -package istio +package nsx-sm import ( "archive/tar" @@ -20,23 +20,23 @@ import ( ) const ( - repoURL = "https://api.github.com/repos/istio/istio/releases/latest" + repoURL = "https://api.github.com/repos/nsx-sm/nsx-sm/releases/latest" urlSuffix = "-linux.tar.gz" crdPattern = "crd(.*)yaml" cachePeriod = 6 * time.Hour ) var ( - localByPassFile = "/app/istio.tar.gz" + localByPassFile = "/app/nsx-sm.tar.gz" - localFile = path.Join(os.TempDir(), "istio.tar.gz") - destinationFolder = path.Join(os.TempDir(), "istio") + localFile = path.Join(os.TempDir(), "nsx-sm.tar.gz") + destinationFolder = path.Join(os.TempDir(), "nsx-sm") basePath = path.Join(destinationFolder, "%s") - installFile = path.Join(basePath, "install/kubernetes/istio-demo.yaml") - installWithmTLSFile = path.Join(basePath, "install/kubernetes/istio-demo-auth.yaml") + installFile = path.Join(basePath, "install/kubernetes/nsx-sm-demo.yaml") + installWithmTLSFile = path.Join(basePath, "install/kubernetes/nsx-sm-demo-auth.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/") + crdFolder = path.Join(basePath, "install/kubernetes/helm/nsx-sm-init/files/") defaultBookInfoDestRulesFile = path.Join(basePath, "samples/bookinfo/networking/destination-rule-all-mtls.yaml") bookInfoRouteToV1AllServicesFile = path.Join(basePath, "samples/bookinfo/networking/virtual-service-all-v1.yaml") @@ -60,7 +60,7 @@ type asset struct { } func (iClient *Client) getLatestReleaseURL() error { - if iClient.istioReleaseDownloadURL == "" || time.Since(iClient.istioReleaseUpdatedAt) > cachePeriod { + if iClient.nsx-smReleaseDownloadURL == "" || time.Since(iClient.nsx-smReleaseUpdatedAt) > cachePeriod { logrus.Debugf("API info url: %s", repoURL) resp, err := http.Get(repoURL) if err != nil { @@ -94,9 +94,9 @@ func (iClient *Client) getLatestReleaseURL() error { if result != nil && result.Assets != nil && len(result.Assets) > 0 { for _, asset := range result.Assets { if strings.HasSuffix(asset.Name, urlSuffix) { - iClient.istioReleaseVersion = strings.Replace(asset.Name, urlSuffix, "", -1) - iClient.istioReleaseDownloadURL = asset.DownloadURL - iClient.istioReleaseUpdatedAt = time.Now() + iClient.nsx-smReleaseVersion = strings.Replace(asset.Name, urlSuffix, "", -1) + iClient.nsx-smReleaseDownloadURL = asset.DownloadURL + iClient.nsx-smReleaseUpdatedAt = time.Now() return nil } } @@ -117,16 +117,16 @@ func (iClient *Client) downloadFile(localFile string) error { } defer dFile.Close() - resp, err := http.Get(iClient.istioReleaseDownloadURL) + resp, err := http.Get(iClient.nsx-smReleaseDownloadURL) if err != nil { - err = errors.Wrapf(err, "unable to download the file from URL: %s", iClient.istioReleaseDownloadURL) + err = errors.Wrapf(err, "unable to download the file from URL: %s", iClient.nsx-smReleaseDownloadURL) logrus.Error(err) return err } defer resp.Body.Close() if resp.StatusCode != http.StatusOK { - err = fmt.Errorf("unable to download the file from URL: %s, status: %s", iClient.istioReleaseDownloadURL, resp.Status) + err = fmt.Errorf("unable to download the file from URL: %s, status: %s", iClient.nsx-smReleaseDownloadURL, resp.Status) logrus.Error(err) return err } @@ -198,17 +198,17 @@ func (iClient *Client) untarPackage(destination, fileToUntar string) error { } } -func (iClient *Client) downloadIstio() (string, error) { +func (iClient *Client) downloadnsx-sm() (string, error) { var fileName string _, err := os.Stat(localByPassFile) if err != nil { - logrus.Debug("preparing to download the latest istio release") + logrus.Debug("preparing to download the latest nsx-sm release") err := iClient.getLatestReleaseURL() if err != nil { return "", err } - fileName = iClient.istioReleaseVersion - downloadURL := iClient.istioReleaseDownloadURL + fileName = iClient.nsx-smReleaseVersion + downloadURL := iClient.nsx-smReleaseDownloadURL logrus.Debugf("retrieved latest file name: %s and download url: %s", fileName, downloadURL) proceedWithDownload := true @@ -230,7 +230,7 @@ func (iClient *Client) downloadIstio() (string, error) { } } else { localFile = localByPassFile - fileName = os.Getenv("ISTIO_VERSION") + fileName = os.Getenv("nsx-sm_VERSION") logrus.Debugf("using local bypass file: %s & version name from env: %s", localFile, fileName) } if err = iClient.untarPackage(destinationFolder, localFile); err != nil { @@ -240,8 +240,8 @@ func (iClient *Client) downloadIstio() (string, error) { return fileName, nil } -func (iClient *Client) getIstioComponentYAML(fileName string) (string, error) { - specificVersionName, err := iClient.downloadIstio() +func (iClient *Client) getnsx-smComponentYAML(fileName string) (string, error) { + specificVersionName, err := iClient.downloadnsx-sm() if err != nil { return "", err } @@ -276,7 +276,7 @@ func (iClient *Client) getCRDsYAML() ([]string, error) { return nil, err } - specificVersionName, err := iClient.downloadIstio() + specificVersionName, err := iClient.downloadnsx-sm() if err != nil { return nil, err } @@ -301,45 +301,45 @@ func (iClient *Client) getCRDsYAML() ([]string, error) { return res, nil } -func (iClient *Client) getLatestIstioYAML(installmTLS bool) (string, error) { +func (iClient *Client) getLatestnsx-smYAML(installmTLS bool) (string, error) { if installmTLS { - return iClient.getIstioComponentYAML(installWithmTLSFile) + return iClient.getnsx-smComponentYAML(installWithmTLSFile) } - return iClient.getIstioComponentYAML(installFile) + return iClient.getnsx-smComponentYAML(installFile) } func (iClient *Client) getBookInfoAppYAML() (string, error) { - return iClient.getIstioComponentYAML(bookInfoInstallFile) + return iClient.getnsx-smComponentYAML(bookInfoInstallFile) } func (iClient *Client) getBookInfoGatewayYAML() (string, error) { - return iClient.getIstioComponentYAML(bookInfoGatewayInstallFile) + return iClient.getnsx-smComponentYAML(bookInfoGatewayInstallFile) } func (iClient *Client) getBookInfoDefaultDesinationRulesYAML() (string, error) { - return iClient.getIstioComponentYAML(defaultBookInfoDestRulesFile) + return iClient.getnsx-smComponentYAML(defaultBookInfoDestRulesFile) } func (iClient *Client) getBookInfoRouteToV1AllServicesYAML() (string, error) { - return iClient.getIstioComponentYAML(bookInfoRouteToV1AllServicesFile) + return iClient.getnsx-smComponentYAML(bookInfoRouteToV1AllServicesFile) } func (iClient *Client) getBookInfoRouteToReviewsV2ForJasonFile() (string, error) { - return iClient.getIstioComponentYAML(bookInfoRouteToReviewsV2ForJasonFile) + return iClient.getnsx-smComponentYAML(bookInfoRouteToReviewsV2ForJasonFile) } func (iClient *Client) getBookInfoCanary50pcReviewsV3File() (string, error) { - return iClient.getIstioComponentYAML(bookInfoCanary50pcReviewsV3File) + return iClient.getnsx-smComponentYAML(bookInfoCanary50pcReviewsV3File) } func (iClient *Client) getBookInfoCanary100pcReviewsV3File() (string, error) { - return iClient.getIstioComponentYAML(bookInfoCanary100pcReviewsV3File) + return iClient.getnsx-smComponentYAML(bookInfoCanary100pcReviewsV3File) } func (iClient *Client) getBookInfoInjectDelayForRatingsForJasonFile() (string, error) { - return iClient.getIstioComponentYAML(bookInfoInjectDelayForRatingsForJasonFile) + return iClient.getnsx-smComponentYAML(bookInfoInjectDelayForRatingsForJasonFile) } func (iClient *Client) getBookInfoInjectHTTPAbortToRatingsForJasonFile() (string, error) { - return iClient.getIstioComponentYAML(bookInfoInjectHTTPAbortToRatingsForJasonFile) + return iClient.getnsx-smComponentYAML(bookInfoInjectHTTPAbortToRatingsForJasonFile) } diff --git a/istio/install-smi-istio.go b/nsx-sm/install-smi-nsx-sm.go similarity index 90% rename from istio/install-smi-istio.go rename to nsx-sm/install-smi-nsx-sm.go index f9ec6a4..0fe2d45 100644 --- a/istio/install-smi-istio.go +++ b/nsx-sm/install-smi-nsx-sm.go @@ -1,4 +1,4 @@ -package istio +package nsx-sm import ( "io/ioutil" @@ -9,7 +9,7 @@ import ( "github.com/sirupsen/logrus" ) -const smiBasePath = "istio/config_templates/smi/" +const smiBasePath = "nsx-sm/config_templates/smi/" var smiFiles = []string{ "split_v1alpha1_trafficsplit_crd.yaml", diff --git a/istio/install-smi-istio_test.go b/nsx-sm/install-smi-nsx-sm_test.go similarity index 97% rename from istio/install-smi-istio_test.go rename to nsx-sm/install-smi-nsx-sm_test.go index 2abef8d..8dcdde1 100644 --- a/istio/install-smi-istio_test.go +++ b/nsx-sm/install-smi-nsx-sm_test.go @@ -1,4 +1,4 @@ -package istio +package nsx-sm import ( "testing" diff --git a/istio/istio.go b/nsx-sm/nsx-sm.go similarity index 95% rename from istio/istio.go rename to nsx-sm/nsx-sm.go index d245f56..d14949a 100644 --- a/istio/istio.go +++ b/nsx-sm/nsx-sm.go @@ -12,7 +12,7 @@ // See the License for the specific language governing permissions and // limitations under the License. -package istio +package nsx-sm import ( "bytes" @@ -27,7 +27,7 @@ import ( "time" "github.com/ghodss/yaml" - "github.com/layer5io/meshery-istio/meshes" + "github.com/layer5io/meshery-nsx-sm/meshes" "github.com/pkg/errors" "github.com/sirupsen/logrus" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -37,7 +37,7 @@ import ( ) const ( - hipsterShopIstioManifestsURL = "https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/master/release/istio-manifests.yaml" + hipsterShopnsx-smManifestsURL = "https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/master/release/nsx-sm-manifests.yaml" hipsterShopKubernetesManifestsURL = "https://raw.githubusercontent.com/GoogleCloudPlatform/microservices-demo/master/release/kubernetes-manifests.yaml" ) @@ -54,7 +54,7 @@ func (iClient *Client) CreateMeshInstance(_ context.Context, k8sReq *meshes.Crea ic, err := newClient(k8sConfig, contextName) if err != nil { - err = errors.Wrapf(err, "unable to create a new istio client") + err = errors.Wrapf(err, "unable to create a new nsx-sm client") logrus.Error(err) return nil, err } @@ -171,7 +171,7 @@ func (iClient *Client) updateResource(ctx context.Context, res schema.GroupVersi // MeshName just returns the name of the mesh the client is representing func (iClient *Client) MeshName(context.Context, *meshes.MeshNameRequest) (*meshes.MeshNameResponse, error) { - return &meshes.MeshNameResponse{Name: "Istio"}, nil + return &meshes.MeshNameResponse{Name: "nsx-sm"}, nil } func (iClient *Client) applyRulePayload(ctx context.Context, namespace string, newBytes []byte, delete, isCustomOp bool) error { @@ -292,7 +292,7 @@ RETRY: return nil } -func (iClient *Client) applyIstioCRDs(ctx context.Context, delete bool) error { +func (iClient *Client) applynsx-smCRDs(ctx context.Context, delete bool) error { crdYAMLs, err := iClient.getCRDsYAML() if err != nil { return err @@ -336,7 +336,7 @@ func (iClient *Client) labelNamespaceForAutoInjection(ctx context.Context, names ns.SetName(namespace) } ns.SetLabels(map[string]string{ - "istio-injection": "enabled", + "nsx-sm-injection": "enabled", }) err = iClient.updateResource(ctx, res, ns) if err != nil { @@ -358,7 +358,7 @@ func (iClient *Client) createNamespace(ctx context.Context, namespace string) er } func (iClient *Client) executeTemplate(ctx context.Context, username, namespace, templateName string) (string, error) { - tmpl, err := template.ParseFiles(path.Join("istio", "config_templates", templateName)) + tmpl, err := template.ParseFiles(path.Join("nsx-sm", "config_templates", templateName)) if err != nil { err = errors.Wrapf(err, "unable to parse template") logrus.Error(err) @@ -380,13 +380,13 @@ func (iClient *Client) executeTemplate(ctx context.Context, username, namespace, func (iClient *Client) executeInstall(ctx context.Context, installmTLS bool, arReq *meshes.ApplyRuleRequest) error { arReq.Namespace = "" if arReq.DeleteOp { - defer iClient.applyIstioCRDs(ctx, arReq.DeleteOp) + defer iClient.applynsx-smCRDs(ctx, arReq.DeleteOp) } else { - if err := iClient.applyIstioCRDs(ctx, arReq.DeleteOp); err != nil { + if err := iClient.applynsx-smCRDs(ctx, arReq.DeleteOp); err != nil { return err } } - yamlFileContents, err := iClient.getLatestIstioYAML(installmTLS) + yamlFileContents, err := iClient.getLatestnsx-smYAML(installmTLS) if err != nil { return err } @@ -451,12 +451,12 @@ func (iClient *Client) executeHipsterShopInstall(ctx context.Context, arReq *mes if err != nil { return err } - istioManifestsContent, err := hipsterShopFilecontents(hipsterShopIstioManifestsURL) + nsx-smManifestsContent, err := hipsterShopFilecontents(hipsterShopnsx-smManifestsURL) if err != nil { return err } - var yamlFileContents = fmt.Sprintf("%s\n---\n%s", kubernetesManifestsContent, istioManifestsContent) + var yamlFileContents = fmt.Sprintf("%s\n---\n%s", kubernetesManifestsContent, nsx-smManifestsContent) if err := iClient.applyConfigChange(ctx, yamlFileContents, arReq.Namespace, arReq.DeleteOp, false); err != nil { return err @@ -486,10 +486,10 @@ func (iClient *Client) ApplyOperation(ctx context.Context, arReq *meshes.ApplyRu isCustomOp := false switch arReq.OpName { - case installmTLSIstioCommand: + case installmTLSnsx-smCommand: installWithmTLS = true fallthrough - case installIstioCommand: + case installnsx-smCommand: go func() { opName1 := "deploying" if arReq.DeleteOp { @@ -499,7 +499,7 @@ func (iClient *Client) ApplyOperation(ctx context.Context, arReq *meshes.ApplyRu iClient.eventChan <- &meshes.EventsResponse{ OperationId: arReq.OperationId, EventType: meshes.EventType_ERROR, - Summary: fmt.Sprintf("Error while %s Istio", opName1), + Summary: fmt.Sprintf("Error while %s nsx-sm", opName1), Details: err.Error(), } return @@ -511,8 +511,8 @@ func (iClient *Client) ApplyOperation(ctx context.Context, arReq *meshes.ApplyRu 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), + Summary: fmt.Sprintf("nsx-sm %s successfully", opName), + Details: fmt.Sprintf("The latest version of nsx-sm is now %s.", opName), } return }() @@ -573,7 +573,7 @@ func (iClient *Client) ApplyOperation(ctx context.Context, arReq *meshes.ApplyRu OperationId: arReq.OperationId, EventType: meshes.EventType_INFO, Summary: fmt.Sprintf("Book Info app %s successfully", opName), - Details: fmt.Sprintf("The Istio canonical Book Info app is now %s.", opName), + Details: fmt.Sprintf("The nsx-sm canonical Book Info app is now %s.", opName), } return }() diff --git a/istio/supported_ops.go b/nsx-sm/supported_ops.go similarity index 86% rename from istio/supported_ops.go rename to nsx-sm/supported_ops.go index e583435..114cc39 100644 --- a/istio/supported_ops.go +++ b/nsx-sm/supported_ops.go @@ -12,9 +12,9 @@ // See the License for the specific language governing permissions and // limitations under the License. -package istio +package nsx-sm -import "github.com/layer5io/meshery-istio/meshes" +import "github.com/layer5io/meshery-nsx-sm/meshes" type supportedOperation struct { // a friendly name @@ -26,9 +26,9 @@ type supportedOperation struct { const ( customOpCommand = "custom" - runVet = "istio_vet" - installIstioCommand = "istio_install" - installmTLSIstioCommand = "istio_mtls_install" + runVet = "nsx-sm_vet" + installnsx-smCommand = "nsx-sm_install" + installmTLSnsx-smCommand = "nsx-sm_mtls_install" installBookInfoCommand = "install_book_info" cbCommand = "cb1" installSMI = "install_smi" @@ -45,25 +45,25 @@ const ( ) var supportedOps = map[string]supportedOperation{ - installIstioCommand: { - name: "Latest Istio without mTLS", - // templateName: "install_istio.tmpl", + installnsx-smCommand: { + name: "Latest nsx-sm without mTLS", + // templateName: "install_nsx-sm.tmpl", opType: meshes.OpCategory_INSTALL, }, - installmTLSIstioCommand: { - name: "Latest Istio with mTLS", + installmTLSnsx-smCommand: { + name: "Latest nsx-sm with mTLS", opType: meshes.OpCategory_INSTALL, }, installBookInfoCommand: { name: "Book Info Application", - // templateName: "install_istio.tmpl", + // templateName: "install_nsx-sm.tmpl", opType: meshes.OpCategory_SAMPLE_APPLICATION, }, runVet: { - name: "Run istio-vet", + name: "Run nsx-sm-vet", opType: meshes.OpCategory_VALIDATE, - // templateName: "istio_vet.tmpl", - // appLabel: "istio-vet", + // templateName: "nsx-sm_vet.tmpl", + // appLabel: "nsx-sm-vet", // returnLogs: true, }, cbCommand: { @@ -105,7 +105,7 @@ var supportedOps = map[string]supportedOperation{ templateName: "book_info_product_page_circuit_breaking.tmpl", }, installSMI: { - name: "Service Mesh Interface (SMI) Istio Adapter", + name: "Service Mesh Interface (SMI) nsx-sm Adapter", opType: meshes.OpCategory_INSTALL, }, installHTTPBin: { diff --git a/istio/vet.go b/nsx-sm/vet.go similarity index 69% rename from istio/vet.go rename to nsx-sm/vet.go index 77879a6..9dc16bd 100644 --- a/istio/vet.go +++ b/nsx-sm/vet.go @@ -1,52 +1,52 @@ -package istio +package nsx-sm import ( "fmt" "strings" - istioinformer "github.com/aspenmesh/istio-client-go/pkg/client/informers/externalversions" - "github.com/aspenmesh/istio-vet/pkg/istioclient" - "github.com/aspenmesh/istio-vet/pkg/vetter" - "github.com/aspenmesh/istio-vet/pkg/vetter/applabel" - "github.com/aspenmesh/istio-vet/pkg/vetter/conflictingvirtualservicehost" - "github.com/aspenmesh/istio-vet/pkg/vetter/danglingroutedestinationhost" - "github.com/aspenmesh/istio-vet/pkg/vetter/meshversion" - "github.com/aspenmesh/istio-vet/pkg/vetter/mtlsprobes" - "github.com/aspenmesh/istio-vet/pkg/vetter/podsinmesh" - "github.com/aspenmesh/istio-vet/pkg/vetter/serviceassociation" - "github.com/aspenmesh/istio-vet/pkg/vetter/serviceportprefix" - "github.com/layer5io/meshery-istio/meshes" + nsx-sminformer "github.com/aspenmesh/nsx-sm-client-go/pkg/client/informers/externalversions" + "github.com/aspenmesh/nsx-sm-vet/pkg/nsx-smclient" + "github.com/aspenmesh/nsx-sm-vet/pkg/vetter" + "github.com/aspenmesh/nsx-sm-vet/pkg/vetter/applabel" + "github.com/aspenmesh/nsx-sm-vet/pkg/vetter/conflictingvirtualservicehost" + "github.com/aspenmesh/nsx-sm-vet/pkg/vetter/danglingroutedestinationhost" + "github.com/aspenmesh/nsx-sm-vet/pkg/vetter/meshversion" + "github.com/aspenmesh/nsx-sm-vet/pkg/vetter/mtlsprobes" + "github.com/aspenmesh/nsx-sm-vet/pkg/vetter/podsinmesh" + "github.com/aspenmesh/nsx-sm-vet/pkg/vetter/serviceassociation" + "github.com/aspenmesh/nsx-sm-vet/pkg/vetter/serviceportprefix" + "github.com/layer5io/meshery-nsx-sm/meshes" "github.com/pkg/errors" "github.com/sirupsen/logrus" "k8s.io/client-go/informers" - apiv1 "github.com/aspenmesh/istio-vet/api/v1" + apiv1 "github.com/aspenmesh/nsx-sm-vet/api/v1" ) type metaInformerFactory struct { k8s informers.SharedInformerFactory - istio istioinformer.SharedInformerFactory + nsx-sm nsx-sminformer.SharedInformerFactory } func (m *metaInformerFactory) K8s() informers.SharedInformerFactory { return m.k8s } -func (m *metaInformerFactory) Istio() istioinformer.SharedInformerFactory { - return m.istio +func (m *metaInformerFactory) nsx-sm() nsx-sminformer.SharedInformerFactory { + return m.nsx-sm } func (iClient *Client) runVet() error { - istioClient, err := istioclient.New(iClient.config) + nsx-smClient, err := nsx-smclient.New(iClient.config) if err != nil { - err = errors.Wrap(err, "unable to create a new istio client") + err = errors.Wrap(err, "unable to create a new nsx-sm client") return err } kubeInformerFactory := informers.NewSharedInformerFactory(iClient.k8sClientset, 0) - istioInformerFactory := istioinformer.NewSharedInformerFactory(istioClient, 0) + nsx-smInformerFactory := nsx-sminformer.NewSharedInformerFactory(nsx-smClient, 0) informerFactory := &metaInformerFactory{ k8s: kubeInformerFactory, - istio: istioInformerFactory, + nsx-sm: nsx-smInformerFactory, } vList := []vetter.Vetter{ @@ -72,8 +72,8 @@ func (iClient *Client) runVet() error { } } - istioInformerFactory.Start(stopCh) - oks = istioInformerFactory.WaitForCacheSync(stopCh) + nsx-smInformerFactory.Start(stopCh) + oks = nsx-smInformerFactory.WaitForCacheSync(stopCh) for inf, ok := range oks { if !ok { err := errors.Errorf("Failed to sync %s", inf) diff --git a/istio/yaml.go b/nsx-sm/yaml.go similarity index 96% rename from istio/yaml.go rename to nsx-sm/yaml.go index 2ad9011..ae369a3 100644 --- a/istio/yaml.go +++ b/nsx-sm/yaml.go @@ -1,4 +1,4 @@ -package istio +package nsx-sm import ( "bufio" @@ -23,7 +23,7 @@ type YAMLDecoder struct { func NewDocumentDecoder(r io.ReadCloser) io.ReadCloser { b := make([]byte, 4096) scanner := bufio.NewScanner(r) - scanner.Buffer(b, 256*1024) // overriding: the size of the buffer used was small when loading large sections from istio deployment yaml + scanner.Buffer(b, 256*1024) // overriding: the size of the buffer used was small when loading large sections from nsx-sm deployment yaml scanner.Split(splitYAMLDocument) return &YAMLDecoder{ r: r,