Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Istio multi-cluster #447

Merged
merged 6 commits into from
Feb 20, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions charts/flagger/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,11 +42,31 @@ spec:
imagePullSecrets:
- name: {{ .Values.image.pullSecret }}
{{- end }}
volumes:
{{- if .Values.kubeconfigHost }}
- name: kubeconfig
secret:
secretName: "{{ .Values.kubeconfigHost }}"
{{- end }}
{{- if .Values.kubeconfigSource }}
- name: kubeconfig-source
secret:
secretName: "{{ .Values.kubeconfigSource }}"
{{- end }}
containers:
- name: flagger
securityContext:
readOnlyRootFilesystem: true
runAsUser: 10001
volumeMounts:
{{- if .Values.kubeconfigHost }}
- name: kubeconfig
mountPath: "/tmp/istio-host"
{{- end }}
{{- if .Values.kubeconfigSource }}
- name: kubeconfig-source
mountPath: "/tmp/istio-source"
{{- end }}
image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
ports:
Expand Down Expand Up @@ -90,6 +110,12 @@ spec:
{{- if .Values.eventWebhook }}
- -event-webhook={{ .Values.eventWebhook }}
{{- end }}
{{- if .Values.kubeconfigSource }}
- -kubeconfig=/tmp/istio-source/config1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace config1 with kubeconfig

{{- end }}
{{- if .Values.kubeconfigHost }}
- -kubeconfig-host=/tmp/istio-host/config1
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace config1 with kubeconfig

{{- end }}
livenessProbe:
exec:
command:
Expand Down
3 changes: 3 additions & 0 deletions charts/flagger/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ tolerations: []
prometheus:
# to be used with ingress controllers
install: false

kubeconfigSource: ""
kubeconfigHost: "kubeconfig"
viditganpi marked this conversation as resolved.
Show resolved Hide resolved
18 changes: 13 additions & 5 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 @@ -111,20 +113,26 @@ func main() {
if err != nil {
logger.Fatalf("Error building kubeconfig: %v", err)
}

fmt.Println(cfg)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this please.

kubeClient, err := kubernetes.NewForConfig(cfg)
if err != nil {
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
Binary file added main
Binary file not shown.