summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--deployments/helm/servicemesh/istio/README.md20
-rw-r--r--deployments/helm/servicemesh/istio/istio-instance/.helmignore22
-rw-r--r--deployments/helm/servicemesh/istio/istio-instance/Chart.yaml22
-rw-r--r--deployments/helm/servicemesh/istio/istio-instance/templates/_helpers.tpl63
-rw-r--r--deployments/helm/servicemesh/istio/istio-instance/templates/istio-sds.yaml50
-rw-r--r--deployments/helm/servicemesh/istio/istio-instance/values.yaml39
-rw-r--r--src/k8splugin/internal/plugin/helpers.go35
7 files changed, 227 insertions, 24 deletions
diff --git a/deployments/helm/servicemesh/istio/README.md b/deployments/helm/servicemesh/istio/README.md
new file mode 100644
index 00000000..8fcba4f8
--- /dev/null
+++ b/deployments/helm/servicemesh/istio/README.md
@@ -0,0 +1,20 @@
+#/*
+# * Copyright 2019 Intel Corporation, Inc
+# *
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# */
+
+# Steps for Instaling Istio with Istio- Operator
+
+# Step 1 - Add the helm chart to install Istio in sds configuration
+helm install istio-instance --name istio --namespace istio-system
diff --git a/deployments/helm/servicemesh/istio/istio-instance/.helmignore b/deployments/helm/servicemesh/istio/istio-instance/.helmignore
new file mode 100644
index 00000000..50af0317
--- /dev/null
+++ b/deployments/helm/servicemesh/istio/istio-instance/.helmignore
@@ -0,0 +1,22 @@
+# Patterns to ignore when building packages.
+# This supports shell glob matching, relative path matching, and
+# negation (prefixed with !). Only one pattern per line.
+.DS_Store
+# Common VCS dirs
+.git/
+.gitignore
+.bzr/
+.bzrignore
+.hg/
+.hgignore
+.svn/
+# Common backup files
+*.swp
+*.bak
+*.tmp
+*~
+# Various IDEs
+.project
+.idea/
+*.tmproj
+.vscode/
diff --git a/deployments/helm/servicemesh/istio/istio-instance/Chart.yaml b/deployments/helm/servicemesh/istio/istio-instance/Chart.yaml
new file mode 100644
index 00000000..ca2ff626
--- /dev/null
+++ b/deployments/helm/servicemesh/istio/istio-instance/Chart.yaml
@@ -0,0 +1,22 @@
+
+#/*
+# * Copyright 2019 Intel Corporation, Inc
+# *
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# */
+
+apiVersion: v1
+appVersion: "1.0"
+description: A Helm chart for Istio
+name: istio-instance
+version: 0.1.0
diff --git a/deployments/helm/servicemesh/istio/istio-instance/templates/_helpers.tpl b/deployments/helm/servicemesh/istio/istio-instance/templates/_helpers.tpl
new file mode 100644
index 00000000..c2e7c701
--- /dev/null
+++ b/deployments/helm/servicemesh/istio/istio-instance/templates/_helpers.tpl
@@ -0,0 +1,63 @@
+#/*
+# * Copyright 2019 Intel Corporation, Inc
+# *
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# */
+
+
+{{/*
+Expand the name of the chart.
+*/}}
+{{- define "Chart-name.name" -}}
+{{- default .Chart.name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Create a default fully qualified app name.
+We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
+If release name contains chart name it will be used as a full name.
+*/}}
+{{- define "istio.fullname" -}}
+{{- if .Values.fullnameOverride -}}
+{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- $name := default .Chart.Name .Values.nameOverride -}}
+{{- if contains $name .Release.Name -}}
+{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
+{{- else -}}
+{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+{{- end -}}
+{{- end -}}
+
+{{/*
+Create chart name and version as used by the chart label.
+*/}}
+{{- define "istio.chart" -}}
+{{- .Chart.Name | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Create a fully qualified configmap name.
+*/}}
+{{- define "istio.configmap.fullname" -}}
+{{- printf "%s-%s" .Release.Name "istio-mesh-config" | trunc 63 | trimSuffix "-" -}}
+{{- end -}}
+
+{{/*
+Configmap checksum.
+*/}}
+{{- define "istio.configmap.checksum" -}}
+{{- print $.Template.BasePath "/configmap.yaml" | sha256sum -}}
+{{- end -}}
+
diff --git a/deployments/helm/servicemesh/istio/istio-instance/templates/istio-sds.yaml b/deployments/helm/servicemesh/istio/istio-instance/templates/istio-sds.yaml
new file mode 100644
index 00000000..8c440a4e
--- /dev/null
+++ b/deployments/helm/servicemesh/istio/istio-instance/templates/istio-sds.yaml
@@ -0,0 +1,50 @@
+
+
+#/*Copyright 2019 Intel Corporation, Inc
+# *
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# */
+apiVersion: istio.banzaicloud.io/v1beta1
+kind: Istio
+metadata:
+ labels:
+ controller-tools.k8s.io: "1.0"
+ name: {{ .Values.metadata.name }}
+spec:
+ version: {{ .Values.spec.version | quote }}
+ mtls: {{ .Values.spec.mtls }}
+ autoInjectionNamespaces: {{- range .Values.spec.autoInjectionNamespaces }}
+ - {{ . | quote }}
+ {{- end }}
+ sds:
+ enabled: {{ .Values.spec.sds.enabled }}
+ udsPath: {{ .Values.spec.sds.udsPath | quote }}
+ useTrustworthyJwt: {{ .Values.spec.sds.useTrustworthyJwt }}
+ useNormalJwt: {{ .Values.spec.sds.useNormalJwt }}
+ gateways:
+ enabled: {{ .Values.spec.gateways.enabled }}
+ ingress:
+ enabled: {{ .Values.spec.gateways.ingress.enabled }}
+ sds:
+ enabled: {{ .Values.spec.gateways.ingress.sds.enabled }}
+ image: {{ .Values.spec.gateways.ingress.sds.image | quote }}
+ resources: {}
+ # requests:
+ # cpu: 100m
+ # memory: 128Mi
+ # limits:
+ # cpu: 2000m
+ # memory: 1024Mi
+ nodeAgent:
+ enabled: {{ .Values.spec.nodeAgent.enabled }}
+ image: {{ .Values.spec.nodeAgent.image | quote }}
diff --git a/deployments/helm/servicemesh/istio/istio-instance/values.yaml b/deployments/helm/servicemesh/istio/istio-instance/values.yaml
new file mode 100644
index 00000000..091999ac
--- /dev/null
+++ b/deployments/helm/servicemesh/istio/istio-instance/values.yaml
@@ -0,0 +1,39 @@
+
+#/*
+# * Copyright 2019 Intel Corporation, Inc
+# *
+# * Licensed under the Apache License, Version 2.0 (the "License");
+# * you may not use this file except in compliance with the License.
+# * You may obtain a copy of the License at
+# *
+# * http://www.apache.org/licenses/LICENSE-2.0
+# *
+# * Unless required by applicable law or agreed to in writing, software
+# * distributed under the License is distributed on an "AS IS" BASIS,
+# * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# * See the License for the specific language governing permissions and
+# * limitations under the License.
+# */
+#Declare variables to be passed into Istio SDS template file.
+metadata:
+ name: "istio-sample"
+spec:
+ version: "1.2.2"
+ mtls: true
+ autoInjectionNamespaces:
+ -
+ sds:
+ enabled: true
+ udsPath: "unix:/var/run/sds/uds_path"
+ useTrustworthyJwt: false
+ useNormalJwt: true
+ gateways:
+ enabled: true
+ ingress:
+ enabled: true
+ sds:
+ enabled: true
+ image: "docker.io/istio/node-agent-k8s:1.2.2"
+ nodeAgent:
+ enabled: true
+ image : "docker.io/istio/node-agent-k8s:1.2.2"
diff --git a/src/k8splugin/internal/plugin/helpers.go b/src/k8splugin/internal/plugin/helpers.go
index b5c9109c..ad785ab7 100644
--- a/src/k8splugin/internal/plugin/helpers.go
+++ b/src/k8splugin/internal/plugin/helpers.go
@@ -17,7 +17,6 @@
package plugin
import (
- "encoding/json"
"log"
"strings"
@@ -29,6 +28,7 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/api/meta"
"k8s.io/apimachinery/pkg/apis/meta/v1/unstructured"
+ "k8s.io/apimachinery/pkg/runtime"
"k8s.io/apimachinery/pkg/runtime/schema"
"k8s.io/client-go/dynamic"
"k8s.io/client-go/kubernetes"
@@ -107,44 +107,31 @@ func TagPodsIfPresent(unstruct *unstructured.Unstructured, tag string) {
log.Println("Error converting spec to map")
return
}
+
template, ok := spec["template"].(map[string]interface{})
if !ok {
log.Println("Error converting template to map")
return
}
- data, err := json.Marshal(template)
- if err != nil {
- log.Println("Error Marshaling Podspec")
- return
- }
-
//Attempt to convert the template to a podtemplatespec.
//This is to check if we have any pods being created.
podTemplateSpec := &corev1.PodTemplateSpec{}
- _, err = podTemplateSpec.MarshalTo(data)
+ err := runtime.DefaultUnstructuredConverter.FromUnstructured(template, podTemplateSpec)
if err != nil {
- log.Println("Did not find a podTemplateSpec" + err.Error())
+ log.Println("Did not find a podTemplateSpec: " + err.Error())
return
}
- //At this point, we know that the data contains a PodTemplateSpec
- metadata, ok := template["metadata"].(map[string]interface{})
- if !ok {
- log.Println("Error converting metadata to map")
- return
- }
-
- //Get the labels map
- labels, ok := metadata["labels"].(map[string]string)
- if !ok {
- log.Println("Error converting labels to map")
- return
- }
-
- //Check if labels exist for this object
+ labels := podTemplateSpec.GetLabels()
if labels == nil {
labels = map[string]string{}
}
labels[config.GetConfiguration().KubernetesLabelName] = tag
+ podTemplateSpec.SetLabels(labels)
+
+ updatedTemplate, err := runtime.DefaultUnstructuredConverter.ToUnstructured(podTemplateSpec)
+
+ //Set the label
+ spec["template"] = updatedTemplate
}