diff --git a/common/const.go b/common/const.go index 0ed51c20..1c7330d8 100644 --- a/common/const.go +++ b/common/const.go @@ -155,49 +155,49 @@ ExecStartPre=/bin/sh -xc '! /usr/bin/systemctl is-enabled --quiet nm-cloud-setup ExecStartPre=-/sbin/modprobe br_netfilter ExecStartPre=-/sbin/modprobe overlay ExecStart=/usr/local/bin/k3s \ - {{if .TypeMaster -}} + {{- if .TypeMaster}} server \ --tls-san kubeapi.corp.cc \ --tls-san apiserver.cluster.local \ --tls-san {{ .KubeAPI }} \ - {{if .PodCIDR -}} - --cluster-cidr {{ .PodCIDR }} \ - {{end -}} - {{if .ServiceCIDR -}} - --service-cidr {{ .ServiceCIDR }} \ - {{end -}} - {{if .DataStore -}} - --datastore-endpoint {{ .DataStore }} \ - {{else -}} + {{- if .PodCIDR }} + --cluster-cidr {{ .PodCIDR }} \ + {{- end -}} + {{- if .ServiceCIDR }} + --service-cidr {{ .ServiceCIDR }} \ + {{- end -}} + {{- if .DataStore }} + --datastore-endpoint {{ .DataStore }} \ + {{- else}} {{if not .Master0 -}} - --server https://{{ .KubeAPI }}:6443 \ - {{end -}} - --cluster-init \ - --etcd-expose-metrics \ - --etcd-snapshot-name auto-snapshot \ - --etcd-snapshot-compress \ - {{end -}} - {{if .LocalStorage -}} - --disable servicelb,traefik \ + --server https://{{ .KubeAPI }}:6443 \ + {{ end -}} + --cluster-init \ + --etcd-expose-metrics \ + --etcd-snapshot-name auto-snapshot \ + --etcd-snapshot-compress \ + {{- end -}} + {{- if .LocalStorage }} + --disable servicelb,traefik \ {{else -}} - --disable servicelb,traefik,local-storage \ - {{end -}} + --disable servicelb,traefik,local-storage \ + {{- end -}} --disable-cloud-controller \ --system-default-registry {{ .Registry }} \ --disable-network-policy \ --disable-helm-controller \ - {{if .CNI -}} - --flannel-backend {{ .CNI }} \ + {{if .CNI }} + --flannel-backend {{ .CNI }} \ {{end -}} - {{else -}} - --server https://{{ .KubeAPI }}:6443 \ + {{- else}} agent \ - {{end -}} + --server https://{{ .KubeAPI }}:6443 \ + {{- end }} --token {{ .KubeToken }} \ --data-dir {{.DataDir}} \ - --docker \ --pause-image {{ .Registry }}/rancher/mirrored-pause:3.6 \ --prefer-bundled-bin \ --kube-proxy-arg "proxy-mode=ipvs" "masquerade-all=true" \ - --kube-proxy-arg "metrics-bind-address=0.0.0.0" + --kube-proxy-arg "metrics-bind-address=0.0.0.0" \ + --docker ` diff --git a/internal/pkg/cli/k3stpl/k3stpl.go b/internal/pkg/cli/k3stpl/k3stpl.go index b1b94947..888305ca 100644 --- a/internal/pkg/cli/k3stpl/k3stpl.go +++ b/internal/pkg/cli/k3stpl/k3stpl.go @@ -8,8 +8,8 @@ package k3stpl import ( "bytes" - "html/template" "os" + "text/template" "github.com/ergoapi/util/exnet" "github.com/ergoapi/util/file" @@ -94,5 +94,6 @@ func EmbedCommand(f factory.Factory) *cobra.Command { rootCmd.Flags().BoolVar(&k3sargs.LocalStorage, "local-storage", true, "local-storage") rootCmd.Flags().StringVar(&k3sargs.Master0IP, "master0ip", "", "master0ip, only work offline mode") rootCmd.Flags().StringVar(&k3sargs.Registry, "registry", "hub.zentao.net", "registry") + rootCmd.Flags().StringVar(&k3sargs.DataStore, "datasource", "", "datasource") return rootCmd }