-
Notifications
You must be signed in to change notification settings - Fork 109
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #161 from utkarsh-pro/utkarsh-pro/feature/addons-s…
…upport Add "Check Configuration" and addons support to istio adapter
- Loading branch information
Showing
9 changed files
with
412 additions
and
69 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,26 @@ | ||
FROM golang:1.13.1 as bd | ||
RUN adduser --disabled-login --gecos "" appuser | ||
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.5.1/istio-1.5.1-linux.tar.gz | ||
FROM golang:1.13 as builder | ||
|
||
FROM alpine | ||
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 && \ | ||
mkdir -p /root/.kube && \ | ||
mkdir -p /tmp/istio | ||
COPY --from=bd /meshery-istio /app/ | ||
COPY --from=bd /istio /app/istio | ||
COPY --from=bd /istio.tar.gz /app/ | ||
COPY --from=bd //github.com/layer5io/meshery-istio/scripts /app/scripts/. | ||
COPY --from=bd /etc/passwd /etc/passwd | ||
ENV ISTIO_VERSION=1.7.3 | ||
# USER appuser | ||
WORKDIR /app | ||
CMD ./meshery-istio | ||
ARG ENVIRONMENT="development" | ||
ARG CONFIG_PROVIDER="viper" | ||
WORKDIR /build | ||
# Copy the Go Modules manifests | ||
COPY go.mod go.mod | ||
COPY go.sum go.sum | ||
# cache deps before building and copying source so that we don't need to re-download as much | ||
# and so that source changes don't invalidate our downloaded layer | ||
RUN go mod download | ||
# Copy the go source | ||
COPY main.go main.go | ||
COPY internal/ internal/ | ||
COPY istio/ istio/ | ||
# Build | ||
RUN CGO_ENABLED=1 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -ldflags="-w -s -X main.environment=$ENVIRONMENT -X main.provider=$CONFIG_PROVIDER" -a -o meshery-istio main.go | ||
|
||
# Use distroless as minimal base image to package the manager binary | ||
# Refer to https://github.com/GoogleContainerTools/distroless for more details | ||
FROM gcr.io/distroless/base | ||
WORKDIR / | ||
ENV DISTRO="debian" | ||
ENV GOARCH="amd64" | ||
COPY --from=builder /build/meshery-istio . | ||
ENTRYPOINT ["/meshery-istio"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package istio | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
|
||
"github.com/layer5io/meshery-adapter-library/adapter" | ||
"github.com/layer5io/meshery-adapter-library/status" | ||
"github.com/layer5io/meshery-istio/internal/config" | ||
) | ||
|
||
// AddonTemplate is as a container for addon templates | ||
var AddonTemplate = map[string]adapter.Template{ | ||
config.PrometheusAddon: "https://raw.githubusercontent.com/istio/istio/master/samples/addons/prometheus.yaml", | ||
config.GrafanaAddon: "https://raw.githubusercontent.com/istio/istio/master/samples/addons/grafana.yaml", | ||
config.KialiAddon: "https://raw.githubusercontent.com/istio/istio/master/samples/addons/kiali.yaml", | ||
config.JaegerAddon: "https://raw.githubusercontent.com/istio/istio/master/samples/addons/jaeger.yaml", | ||
config.ZipkinAddon: "https://raw.githubusercontent.com/istio/istio/master/samples/addons/extras/zipkin.yaml", | ||
} | ||
|
||
// InstallAddon installs the specified addon in the given namespace | ||
func (istio *Istio) InstallAddon(namespace string, del bool, addon string) (string, error) { | ||
// Some of addons will have a different install process | ||
// than these template based addons | ||
switch addon { | ||
case config.PrometheusAddon, config.GrafanaAddon, config.KialiAddon, config.JaegerAddon, config.ZipkinAddon: | ||
return istio.installAddonFromTemplate(namespace, del, AddonTemplate[addon]) | ||
} | ||
|
||
return "", ErrAddonInvalidConfig(fmt.Errorf("%s is invalid addon", addon)) | ||
} | ||
|
||
// installAddonFromTemplate installs/uninstalls an addon in the given namespace | ||
// | ||
// the template defines the manifest's link/location which needs to be used to | ||
// install the addon | ||
func (istio *Istio) installAddonFromTemplate(namespace string, del bool, template adapter.Template) (string, error) { | ||
istio.Log.Info(fmt.Sprintf("Requested action is delete: %v", del)) | ||
st := status.Installing | ||
|
||
if del { | ||
st = status.Removing | ||
} | ||
|
||
contents, err := readFileSource(string(template)) | ||
if err != nil { | ||
return st, ErrAddonFromTemplate(err) | ||
} | ||
|
||
err = istio.applyManifest([]byte(contents), del, namespace) | ||
// Specifically choosing to ignore kiali dashboard's error. | ||
// Referring to: https://github.com/kiali/kiali/issues/3112 | ||
if err != nil && !strings.Contains(err.Error(), "no matches for kind \"MonitoringDashboard\" in version \"monitoring.kiali.io/v1alpha1\"") { | ||
return st, ErrAddonFromTemplate(err) | ||
} | ||
|
||
return status.Installed, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.