Skip to content

Commit

Permalink
Merge pull request #447 from viditganpi/canary-for-multi-cluster-istio
Browse files Browse the repository at this point in the history
Add support for Istio multi-cluster
  • Loading branch information
stefanprodan authored Feb 20, 2020
2 parents 91ef812 + 0d493f6 commit ab00a00
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 4 deletions.
14 changes: 14 additions & 0 deletions charts/flagger/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,22 @@ spec:
imagePullSecrets:
- name: {{ .Values.image.pullSecret }}
{{- end }}
volumes:
{{- if .Values.kubeconfigHost }}
- name: kubeconfig
secret:
secretName: "{{ .Values.kubeconfigHost }}"
{{- end }}
containers:
- name: flagger
securityContext:
readOnlyRootFilesystem: true
runAsUser: 10001
volumeMounts:
{{- if .Values.kubeconfigHost }}
- name: kubeconfig
mountPath: "/tmp/istio-host"
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
Expand Down Expand Up @@ -90,6 +101,9 @@ spec:
{{- if .Values.eventWebhook }}
- -event-webhook={{ .Values.eventWebhook }}
{{- end }}
{{- if .Values.kubeconfigHost }}
- -kubeconfig-host=/tmp/istio-host/kubeconfig
{{- end }}
livenessProbe:
exec:
command:
Expand Down
2 changes: 2 additions & 0 deletions charts/flagger/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,5 @@ tolerations: []
prometheus:
# to be used with ingress controllers
install: false

kubeconfigHost: ""
16 changes: 12 additions & 4 deletions cmd/flagger/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ var (
leaderElectionNamespace string
enableConfigTracking bool
ver bool
kubeconfigHost string
)

func init() {
Expand All @@ -83,6 +84,7 @@ func init() {
flag.StringVar(&leaderElectionNamespace, "leader-election-namespace", "kube-system", "Namespace used to create the leader election config map.")
flag.BoolVar(&enableConfigTracking, "enable-config-tracking", true, "Enable secrets and configmaps tracking.")
flag.BoolVar(&ver, "version", false, "Print version")
flag.StringVar(&kubeconfigHost, "kubeconfig-host", "", "Path to a kubeconfig for host cluster. Only required if cluster has a host cluster.")
}

func main() {
Expand Down Expand Up @@ -117,14 +119,20 @@ func main() {
logger.Fatalf("Error building kubernetes clientset: %v", err)
}

meshClient, err := clientset.NewForConfig(cfg)
flaggerClient, err := clientset.NewForConfig(cfg)
if err != nil {
logger.Fatalf("Error building mesh clientset: %v", err)
logger.Fatalf("Error building flagger clientset: %s", err.Error())
}

flaggerClient, err := clientset.NewForConfig(cfg)
//if host kube config is there than this should be spawned with host kubeconfig
cfgHost, err := clientcmd.BuildConfigFromFlags(masterURL, kubeconfigHost)
if err != nil {
logger.Fatalf("Error building flagger clientset: %s", err.Error())
logger.Fatalf("Error building host kubeconfig: %v", err)
}

meshClient, err := clientset.NewForConfig(cfgHost)
if err != nil {
logger.Fatalf("Error building mesh clientset: %v", err)
}

verifyCRDs(flaggerClient, logger)
Expand Down

0 comments on commit ab00a00

Please sign in to comment.