mirror of
https://github.com/kairos-io/provider-k3s.git
synced 2025-05-10 00:46:32 +00:00
PE-6055 fix: use string slice instead of string for k3s args (#106)
* fix: use string slice instead of string for k3s args Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com> * fix: test Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com> --------- Signed-off-by: Nianyu Shen <xiaoyu9964@gmail.com>
This commit is contained in:
parent
965a113cbd
commit
701adfd4a4
@ -37,6 +37,7 @@ BUILD_GOLANG:
|
|||||||
ARG BIN
|
ARG BIN
|
||||||
ARG SRC
|
ARG SRC
|
||||||
ENV CGO_ENABLED=0
|
ENV CGO_ENABLED=0
|
||||||
|
ARG VERSION
|
||||||
ENV GO_LDFLAGS=" -X github.com/kairos-io/provider-k3s/pkg/version.Version=${VERSION} -w -s"
|
ENV GO_LDFLAGS=" -X github.com/kairos-io/provider-k3s/pkg/version.Version=${VERSION} -w -s"
|
||||||
RUN go-build-static.sh -a -o ${BIN} ./${SRC}
|
RUN go-build-static.sh -a -o ${BIN} ./${SRC}
|
||||||
SAVE ARTIFACT ${BIN} ${BIN} AS LOCAL build/${BIN}
|
SAVE ARTIFACT ${BIN} ${BIN} AS LOCAL build/${BIN}
|
||||||
@ -60,8 +61,10 @@ lint:
|
|||||||
RUN golangci-lint run
|
RUN golangci-lint run
|
||||||
|
|
||||||
build-provider:
|
build-provider:
|
||||||
|
DO +VERSION
|
||||||
|
ARG VERSION=$(cat VERSION)
|
||||||
FROM +go-deps
|
FROM +go-deps
|
||||||
DO +BUILD_GOLANG --BIN=agent-provider-k3s --SRC=main.go
|
DO +BUILD_GOLANG --BIN=agent-provider-k3s --SRC=main.go --VERSION=$VERSION
|
||||||
|
|
||||||
build-provider-package:
|
build-provider-package:
|
||||||
DO +VERSION
|
DO +VERSION
|
||||||
|
@ -1,50 +1,50 @@
|
|||||||
package api
|
package api
|
||||||
|
|
||||||
type K3sAgentConfig struct {
|
type K3sAgentConfig struct {
|
||||||
ConfigFile string `json:"config,omitempty" yaml:"config,omitempty"`
|
ConfigFile string `json:"config,omitempty" yaml:"config,omitempty"`
|
||||||
Debug bool `json:"debug,omitempty" yaml:"debug,omitempty"`
|
Debug bool `json:"debug,omitempty" yaml:"debug,omitempty"`
|
||||||
V int `json:"v,omitempty" yaml:"v,omitempty"`
|
V int `json:"v,omitempty" yaml:"v,omitempty"`
|
||||||
VModule string `json:"vmodule,omitempty" yaml:"vmodule,omitempty"`
|
VModule string `json:"vmodule,omitempty" yaml:"vmodule,omitempty"`
|
||||||
Log string `json:"log,omitempty" yaml:"log,omitempty"`
|
Log string `json:"log,omitempty" yaml:"log,omitempty"`
|
||||||
AlsoLogToStderr bool `json:"alsologtostderr,omitempty" yaml:"alsologtostderr,omitempty"`
|
AlsoLogToStderr bool `json:"alsologtostderr,omitempty" yaml:"alsologtostderr,omitempty"`
|
||||||
Token string `json:"token,omitempty" yaml:"token,omitempty"`
|
Token string `json:"token,omitempty" yaml:"token,omitempty"`
|
||||||
TokenFile string `json:"token-file,omitempty" yaml:"token-file,omitempty"`
|
TokenFile string `json:"token-file,omitempty" yaml:"token-file,omitempty"`
|
||||||
Server string `json:"server,omitempty" yaml:"server,omitempty"`
|
Server string `json:"server,omitempty" yaml:"server,omitempty"`
|
||||||
DataDir string `json:"data-dir,omitempty" yaml:"data-dir,omitempty"`
|
DataDir string `json:"data-dir,omitempty" yaml:"data-dir,omitempty"`
|
||||||
NodeName string `json:"node-name,omitempty" yaml:"node-name,omitempty"`
|
NodeName string `json:"node-name,omitempty" yaml:"node-name,omitempty"`
|
||||||
WithNodeID bool `json:"with-node-id,omitempty" yaml:"with-node-id,omitempty"`
|
WithNodeID bool `json:"with-node-id,omitempty" yaml:"with-node-id,omitempty"`
|
||||||
NodeLabels string `json:"node-label,omitempty" yaml:"node-label,omitempty"`
|
NodeLabels []string `json:"node-label,omitempty" yaml:"node-label,omitempty"`
|
||||||
NodeTaints string `json:"node-taint,omitempty" yaml:"node-taint,omitempty"`
|
NodeTaints []string `json:"node-taint,omitempty" yaml:"node-taint,omitempty"`
|
||||||
ImageCredentialProviderBinDir string `json:"image-credential-provider-bin-dir,omitempty" yaml:"image-credential-provider-bin-dir,omitempty"`
|
ImageCredentialProviderBinDir string `json:"image-credential-provider-bin-dir,omitempty" yaml:"image-credential-provider-bin-dir,omitempty"`
|
||||||
ImageCredentialProviderConfig string `json:"image-credential-provider-config,omitempty" yaml:"image-credential-provider-config,omitempty"`
|
ImageCredentialProviderConfig string `json:"image-credential-provider-config,omitempty" yaml:"image-credential-provider-config,omitempty"`
|
||||||
EnableSELinux bool `json:"selinux,omitempty" yaml:"selinux,omitempty"`
|
EnableSELinux bool `json:"selinux,omitempty" yaml:"selinux,omitempty"`
|
||||||
LBServerPort int `json:"lb-server-port,omitempty" yaml:"lb-server-port,omitempty"`
|
LBServerPort int `json:"lb-server-port,omitempty" yaml:"lb-server-port,omitempty"`
|
||||||
ProtectKernelDefaults bool `json:"protect-kernel-defaults,omitempty" yaml:"protect-kernel-defaults,omitempty"`
|
ProtectKernelDefaults bool `json:"protect-kernel-defaults,omitempty" yaml:"protect-kernel-defaults,omitempty"`
|
||||||
ContainerRuntimeEndpoint string `json:"container-runtime-endpoint,omitempty" yaml:"container-runtime-endpoint,omitempty"`
|
ContainerRuntimeEndpoint string `json:"container-runtime-endpoint,omitempty" yaml:"container-runtime-endpoint,omitempty"`
|
||||||
DefaultRuntime string `json:"default-runtime,omitempty" yaml:"default-runtime,omitempty"`
|
DefaultRuntime string `json:"default-runtime,omitempty" yaml:"default-runtime,omitempty"`
|
||||||
ImageServiceEndpoint string `json:"image-service-endpoint,omitempty" yaml:"image-service-endpoint,omitempty"`
|
ImageServiceEndpoint string `json:"image-service-endpoint,omitempty" yaml:"image-service-endpoint,omitempty"`
|
||||||
PauseImage string `json:"pause-image,omitempty" yaml:"pause-image,omitempty"`
|
PauseImage string `json:"pause-image,omitempty" yaml:"pause-image,omitempty"`
|
||||||
Snapshotter string `json:"snapshotter,omitempty" yaml:"snapshotter,omitempty"`
|
Snapshotter string `json:"snapshotter,omitempty" yaml:"snapshotter,omitempty"`
|
||||||
PrivateRegistry string `json:"private-registry,omitempty" yaml:"private-registry,omitempty"`
|
PrivateRegistry string `json:"private-registry,omitempty" yaml:"private-registry,omitempty"`
|
||||||
DisableDefaultRegistryEndpoint bool `json:"disable-default-registry-endpoint,omitempty" yaml:"disable-default-registry-endpoint,omitempty"`
|
DisableDefaultRegistryEndpoint bool `json:"disable-default-registry-endpoint,omitempty" yaml:"disable-default-registry-endpoint,omitempty"`
|
||||||
NonrootDevices bool `json:"nonroot-devices,omitempty" yaml:"nonroot-devices,omitempty"`
|
NonrootDevices bool `json:"nonroot-devices,omitempty" yaml:"nonroot-devices,omitempty"`
|
||||||
AirgapExtraRegistry string `json:"airgap-extra-registry,omitempty" yaml:"airgap-extra-registry,omitempty"`
|
AirgapExtraRegistry []string `json:"airgap-extra-registry,omitempty" yaml:"airgap-extra-registry,omitempty"`
|
||||||
NodeIP string `json:"node-ip,omitempty" yaml:"node-ip,omitempty"`
|
NodeIP []string `json:"node-ip,omitempty" yaml:"node-ip,omitempty"`
|
||||||
BindAddress string `json:"bind-address,omitempty" yaml:"bind-address,omitempty"`
|
BindAddress string `json:"bind-address,omitempty" yaml:"bind-address,omitempty"`
|
||||||
NodeExternalIP string `json:"node-external-ip,omitempty" yaml:"node-external-ip,omitempty"`
|
NodeExternalIP []string `json:"node-external-ip,omitempty" yaml:"node-external-ip,omitempty"`
|
||||||
NodeInternalDNS string `json:"node-internal-dns,omitempty" yaml:"node-internal-dns,omitempty"`
|
NodeInternalDNS []string `json:"node-internal-dns,omitempty" yaml:"node-internal-dns,omitempty"`
|
||||||
NodeExternalDNS string `json:"node-external-dns,omitempty" yaml:"node-external-dns,omitempty"`
|
NodeExternalDNS []string `json:"node-external-dns,omitempty" yaml:"node-external-dns,omitempty"`
|
||||||
ResolvConf string `json:"resolv-conf,omitempty" yaml:"resolv-conf,omitempty"`
|
ResolvConf string `json:"resolv-conf,omitempty" yaml:"resolv-conf,omitempty"`
|
||||||
FlannelIface string `json:"flannel-iface,omitempty" yaml:"flannel-iface,omitempty"`
|
FlannelIface string `json:"flannel-iface,omitempty" yaml:"flannel-iface,omitempty"`
|
||||||
FlannelConf string `json:"flannel-conf,omitempty" yaml:"flannel-conf,omitempty"`
|
FlannelConf string `json:"flannel-conf,omitempty" yaml:"flannel-conf,omitempty"`
|
||||||
FlannelCniConfFile string `json:"flannel-cni-conf,omitempty" yaml:"flannel-cni-conf,omitempty"`
|
FlannelCniConfFile string `json:"flannel-cni-conf,omitempty" yaml:"flannel-cni-conf,omitempty"`
|
||||||
KubeletArg string `json:"kubelet-arg,omitempty" yaml:"kubelet-arg,omitempty"`
|
KubeletArg []string `json:"kubelet-arg,omitempty" yaml:"kubelet-arg,omitempty"`
|
||||||
KubeProxyArg string `json:"kube-proxy-arg,omitempty" yaml:"kube-proxy-arg,omitempty"`
|
KubeProxyArg []string `json:"kube-proxy-arg,omitempty" yaml:"kube-proxy-arg,omitempty"`
|
||||||
EnablePProf bool `json:"enable-pprof,omitempty" yaml:"enable-pprof,omitempty"`
|
EnablePProf bool `json:"enable-pprof,omitempty" yaml:"enable-pprof,omitempty"`
|
||||||
Rootless bool `json:"rootless,omitempty" yaml:"rootless,omitempty"`
|
Rootless bool `json:"rootless,omitempty" yaml:"rootless,omitempty"`
|
||||||
PreferBundledBin bool `json:"prefer-bundled-bin,omitempty" yaml:"prefer-bundled-bin,omitempty"`
|
PreferBundledBin bool `json:"prefer-bundled-bin,omitempty" yaml:"prefer-bundled-bin,omitempty"`
|
||||||
Docker bool `json:"docker,omitempty" yaml:"docker,omitempty"`
|
Docker bool `json:"docker,omitempty" yaml:"docker,omitempty"`
|
||||||
VPNAuth string `json:"vpn-auth,omitempty" yaml:"vpn-auth,omitempty"`
|
VPNAuth string `json:"vpn-auth,omitempty" yaml:"vpn-auth,omitempty"`
|
||||||
VPNAuthFile string `json:"vpn-auth-file,omitempty" yaml:"vpn-auth-file,omitempty"`
|
VPNAuthFile string `json:"vpn-auth-file,omitempty" yaml:"vpn-auth-file,omitempty"`
|
||||||
DisableApiServerLB bool `json:"disable-apiserver-lb,omitempty" yaml:"disable-apiserver-lb,omitempty"`
|
DisableApiServerLB bool `json:"disable-apiserver-lb,omitempty" yaml:"disable-apiserver-lb,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,30 @@ package api
|
|||||||
|
|
||||||
import "time"
|
import "time"
|
||||||
|
|
||||||
|
var StringListKeys = []string{
|
||||||
|
"tls-san",
|
||||||
|
"cluster-cidr",
|
||||||
|
"service-cidr",
|
||||||
|
"cluster-dns",
|
||||||
|
"node-label",
|
||||||
|
"node-taint",
|
||||||
|
"kube-apiserver-arg",
|
||||||
|
"etcd-arg",
|
||||||
|
"kube-controller-manager-arg",
|
||||||
|
"kube-scheduler-arg",
|
||||||
|
"kube-cloud-controller-manager-arg",
|
||||||
|
"disable",
|
||||||
|
"airgap-extra-registry",
|
||||||
|
"node-ip",
|
||||||
|
"node-external-ip",
|
||||||
|
"node-internal-dns",
|
||||||
|
"node-external-dns",
|
||||||
|
"kubelet-arg",
|
||||||
|
"kube-proxy-arg",
|
||||||
|
"kube-controller-arg",
|
||||||
|
"kube-cloud-controller-arg",
|
||||||
|
}
|
||||||
|
|
||||||
type K3sServerConfig struct {
|
type K3sServerConfig struct {
|
||||||
ConfigFile string `json:"config,omitempty" yaml:"config,omitempty"`
|
ConfigFile string `json:"config,omitempty" yaml:"config,omitempty"`
|
||||||
Debug bool `yaml:"debug,omitempty" json:"debug,omitempty"`
|
Debug bool `yaml:"debug,omitempty" json:"debug,omitempty"`
|
||||||
@ -16,13 +40,13 @@ type K3sServerConfig struct {
|
|||||||
ApiServerBindAddress string `yaml:"apiserver-bind-address,omitempty" json:"apiserver-bind-address,omitempty"`
|
ApiServerBindAddress string `yaml:"apiserver-bind-address,omitempty" json:"apiserver-bind-address,omitempty"`
|
||||||
AdvertiseAddress string `yaml:"advertise-address,omitempty" json:"advertise-address,omitempty"`
|
AdvertiseAddress string `yaml:"advertise-address,omitempty" json:"advertise-address,omitempty"`
|
||||||
AdvertisePort int `yaml:"advertise-port,omitempty" json:"advertise-port,omitempty"`
|
AdvertisePort int `yaml:"advertise-port,omitempty" json:"advertise-port,omitempty"`
|
||||||
TLSSan string `yaml:"tls-san,omitempty" json:"tls-san,omitempty"`
|
TLSSan []string `yaml:"tls-san,omitempty" json:"tls-san,omitempty"`
|
||||||
TLSSanSecurity bool `yaml:"tls-san-security,omitempty" json:"tls-san-security,omitempty"`
|
TLSSanSecurity bool `yaml:"tls-san-security,omitempty" json:"tls-san-security,omitempty"`
|
||||||
DataDir string `yaml:"data-dir,omitempty" json:"data-dir,omitempty"`
|
DataDir string `yaml:"data-dir,omitempty" json:"data-dir,omitempty"`
|
||||||
ClusterCIDR string `yaml:"cluster-cidr,omitempty" json:"cluster-cidr,omitempty"`
|
ClusterCIDR []string `yaml:"cluster-cidr,omitempty" json:"cluster-cidr,omitempty"`
|
||||||
ServiceCIDR string `yaml:"service-cidr,omitempty" json:"service-cidr,omitempty"`
|
ServiceCIDR []string `yaml:"service-cidr,omitempty" json:"service-cidr,omitempty"`
|
||||||
ServiceNodePortRange string `yaml:"service-node-port-range,omitempty" json:"service-node-port-range,omitempty"`
|
ServiceNodePortRange string `yaml:"service-node-port-range,omitempty" json:"service-node-port-range,omitempty"`
|
||||||
ClusterDNS string `yaml:"cluster-dns,omitempty" json:"cluster-dns,omitempty"`
|
ClusterDNS []string `yaml:"cluster-dns,omitempty" json:"cluster-dns,omitempty"`
|
||||||
ClusterDomain string `yaml:"cluster-domain,omitempty" json:"cluster-domain,omitempty"`
|
ClusterDomain string `yaml:"cluster-domain,omitempty" json:"cluster-domain,omitempty"`
|
||||||
FlannelBackend string `yaml:"flannel-backend,omitempty" json:"flannel-backend,omitempty"`
|
FlannelBackend string `yaml:"flannel-backend,omitempty" json:"flannel-backend,omitempty"`
|
||||||
FlannelIPv6Masq bool `yaml:"flannel-ipv6-masq,omitempty" json:"flannel-ipv6-masq,omitempty"`
|
FlannelIPv6Masq bool `yaml:"flannel-ipv6-masq,omitempty" json:"flannel-ipv6-masq,omitempty"`
|
||||||
@ -41,11 +65,11 @@ type K3sServerConfig struct {
|
|||||||
ClusterInit bool `yaml:"cluster-init,omitempty" json:"cluster-init,omitempty"`
|
ClusterInit bool `yaml:"cluster-init,omitempty" json:"cluster-init,omitempty"`
|
||||||
ClusterReset bool `yaml:"cluster-reset,omitempty" json:"cluster-reset,omitempty"`
|
ClusterReset bool `yaml:"cluster-reset,omitempty" json:"cluster-reset,omitempty"`
|
||||||
ClusterResetRestorePath string `yaml:"cluster-reset-restore-path,omitempty" json:"cluster-reset-restore-path,omitempty"`
|
ClusterResetRestorePath string `yaml:"cluster-reset-restore-path,omitempty" json:"cluster-reset-restore-path,omitempty"`
|
||||||
KubeApiServerArg string `yaml:"kube-apiserver-arg,omitempty" json:"kube-apiserver-arg,omitempty"`
|
KubeApiServerArg []string `yaml:"kube-apiserver-arg,omitempty" json:"kube-apiserver-arg,omitempty"`
|
||||||
EtcdArg string `yaml:"etcd-arg,omitempty" json:"etcd-arg,omitempty"`
|
EtcdArg []string `yaml:"etcd-arg,omitempty" json:"etcd-arg,omitempty"`
|
||||||
KubeControllerManagerArg string `yaml:"kube-controller-manager-arg,omitempty" json:"kube-controller-manager-arg,omitempty"`
|
KubeControllerManagerArg []string `yaml:"kube-controller-manager-arg,omitempty" json:"kube-controller-manager-arg,omitempty"`
|
||||||
KubeSchedulerArg string `yaml:"kube-scheduler-arg,omitempty" json:"kube-scheduler-arg,omitempty"`
|
KubeSchedulerArg []string `yaml:"kube-scheduler-arg,omitempty" json:"kube-scheduler-arg,omitempty"`
|
||||||
KubeCloudControllerManagerArg string `yaml:"kube-cloud-controller-manager-arg,omitempty" json:"kube-cloud-controller-manager-arg,omitempty"`
|
KubeCloudControllerManagerArg []string `yaml:"kube-cloud-controller-manager-arg,omitempty" json:"kube-cloud-controller-manager-arg,omitempty"`
|
||||||
KineTLS bool `yaml:"kine-tls,omitempty" json:"kine-tls,omitempty"`
|
KineTLS bool `yaml:"kine-tls,omitempty" json:"kine-tls,omitempty"`
|
||||||
DatastoreEndpoint string `yaml:"datastore-endpoint,omitempty" json:"datastore-endpoint,omitempty"`
|
DatastoreEndpoint string `yaml:"datastore-endpoint,omitempty" json:"datastore-endpoint,omitempty"`
|
||||||
DatastoreCaFile string `yaml:"datastore-cafile,omitempty" json:"datastore-cafile,omitempty"`
|
DatastoreCaFile string `yaml:"datastore-cafile,omitempty" json:"datastore-cafile,omitempty"`
|
||||||
@ -72,7 +96,7 @@ type K3sServerConfig struct {
|
|||||||
EtcdS3Insecure bool `json:"etcd-s3-insecure,omitempty" yaml:"etcd-s3-insecure,omitempty"`
|
EtcdS3Insecure bool `json:"etcd-s3-insecure,omitempty" yaml:"etcd-s3-insecure,omitempty"`
|
||||||
EtcdS3Timeout time.Duration `json:"etcd-s3-timeout,omitempty" yaml:"etcd-s3-timeout,omitempty"`
|
EtcdS3Timeout time.Duration `json:"etcd-s3-timeout,omitempty" yaml:"etcd-s3-timeout,omitempty"`
|
||||||
DefaultLocalStoragePath string `yaml:"default-local-storage-path,omitempty" json:"default-local-storage-path,omitempty"`
|
DefaultLocalStoragePath string `yaml:"default-local-storage-path,omitempty" json:"default-local-storage-path,omitempty"`
|
||||||
Disable string `json:"disable,omitempty" yaml:"disable,omitempty"`
|
Disable []string `json:"disable,omitempty" yaml:"disable,omitempty"`
|
||||||
DisableScheduler bool `json:"disable-scheduler,omitempty" yaml:"disable-scheduler,omitempty"`
|
DisableScheduler bool `json:"disable-scheduler,omitempty" yaml:"disable-scheduler,omitempty"`
|
||||||
DisableCloudController bool `json:"disable-cloud-controller,omitempty" yaml:"disable-cloud-controller,omitempty"`
|
DisableCloudController bool `json:"disable-cloud-controller,omitempty" yaml:"disable-cloud-controller,omitempty"`
|
||||||
DisableKubeProxy bool `json:"disable-kube-proxy,omitempty" yaml:"disable-kube-proxy,omitempty"`
|
DisableKubeProxy bool `json:"disable-kube-proxy,omitempty" yaml:"disable-kube-proxy,omitempty"`
|
||||||
@ -85,8 +109,8 @@ type K3sServerConfig struct {
|
|||||||
SupervisorMetrics bool `json:"supervisor-metrics,omitempty" yaml:"supervisor-metrics,omitempty"`
|
SupervisorMetrics bool `json:"supervisor-metrics,omitempty" yaml:"supervisor-metrics,omitempty"`
|
||||||
NodeName string `yaml:"node-name,omitempty" json:"node-name,omitempty"`
|
NodeName string `yaml:"node-name,omitempty" json:"node-name,omitempty"`
|
||||||
WithNodeID bool `json:"with-node-id,omitempty" yaml:"with-node-id,omitempty"`
|
WithNodeID bool `json:"with-node-id,omitempty" yaml:"with-node-id,omitempty"`
|
||||||
NodeLabel string `yaml:"node-label,omitempty" json:"node-label,omitempty"`
|
NodeLabel []string `yaml:"node-label,omitempty" json:"node-label,omitempty"`
|
||||||
NodeTaint string `yaml:"node-taint,omitempty" json:"node-taint,omitempty"`
|
NodeTaint []string `yaml:"node-taint,omitempty" json:"node-taint,omitempty"`
|
||||||
ImageCredentialProviderBinDir string `json:"image-credential-provider-bin-dir,omitempty" yaml:"image-credential-provider-bin-dir,omitempty"`
|
ImageCredentialProviderBinDir string `json:"image-credential-provider-bin-dir,omitempty" yaml:"image-credential-provider-bin-dir,omitempty"`
|
||||||
ImageCredentialProviderConfig string `json:"image-credential-provider-config,omitempty" yaml:"image-credential-provider-config,omitempty"`
|
ImageCredentialProviderConfig string `json:"image-credential-provider-config,omitempty" yaml:"image-credential-provider-config,omitempty"`
|
||||||
Docker bool `json:"docker,omitempty" yaml:"docker,omitempty"`
|
Docker bool `json:"docker,omitempty" yaml:"docker,omitempty"`
|
||||||
@ -99,19 +123,19 @@ type K3sServerConfig struct {
|
|||||||
Snapshotter string `json:"snapshotter,omitempty" yaml:"snapshotter,omitempty"`
|
Snapshotter string `json:"snapshotter,omitempty" yaml:"snapshotter,omitempty"`
|
||||||
PrivateRegistry string `json:"private-registry,omitempty" yaml:"private-registry,omitempty"`
|
PrivateRegistry string `json:"private-registry,omitempty" yaml:"private-registry,omitempty"`
|
||||||
SystemDefaultRegistry string `yaml:"system-default-registry,omitempty" json:"system-default-registry,omitempty"`
|
SystemDefaultRegistry string `yaml:"system-default-registry,omitempty" json:"system-default-registry,omitempty"`
|
||||||
AirgapExtraRegistry string `json:"airgap-extra-registry,omitempty" yaml:"airgap-extra-registry,omitempty"`
|
AirgapExtraRegistry []string `json:"airgap-extra-registry,omitempty" yaml:"airgap-extra-registry,omitempty"`
|
||||||
NodeIP string `yaml:"node-ip,omitempty" json:"node-ip,omitempty"`
|
NodeIP []string `yaml:"node-ip,omitempty" json:"node-ip,omitempty"`
|
||||||
NodeExternalIP string `yaml:"node-external-ip,omitempty" json:"node-external-ip,omitempty"`
|
NodeExternalIP []string `yaml:"node-external-ip,omitempty" json:"node-external-ip,omitempty"`
|
||||||
NodeInternalDNS string `json:"node-internal-dns,omitempty" yaml:"node-internal-dns,omitempty"`
|
NodeInternalDNS []string `json:"node-internal-dns,omitempty" yaml:"node-internal-dns,omitempty"`
|
||||||
NodeExternalDNS string `json:"node-external-dns,omitempty" yaml:"node-external-dns,omitempty"`
|
NodeExternalDNS []string `json:"node-external-dns,omitempty" yaml:"node-external-dns,omitempty"`
|
||||||
ResolvConf string `yaml:"resolv-conf,omitempty" json:"resolv-conf,omitempty"`
|
ResolvConf string `yaml:"resolv-conf,omitempty" json:"resolv-conf,omitempty"`
|
||||||
FlannelIface string `json:"flannel-iface,omitempty" yaml:"flannel-iface,omitempty"`
|
FlannelIface string `json:"flannel-iface,omitempty" yaml:"flannel-iface,omitempty"`
|
||||||
FlannelConf string `json:"flannel-conf,omitempty" yaml:"flannel-conf,omitempty"`
|
FlannelConf string `json:"flannel-conf,omitempty" yaml:"flannel-conf,omitempty"`
|
||||||
FlannelCniConfFile string `json:"flannel-cni-conf,omitempty" yaml:"flannel-cni-conf,omitempty"`
|
FlannelCniConfFile string `json:"flannel-cni-conf,omitempty" yaml:"flannel-cni-conf,omitempty"`
|
||||||
VPNAuth string `json:"vpn-auth,omitempty" yaml:"vpn-auth,omitempty"`
|
VPNAuth string `json:"vpn-auth,omitempty" yaml:"vpn-auth,omitempty"`
|
||||||
VPNAuthFile string `json:"vpn-auth-file,omitempty" yaml:"vpn-auth-file,omitempty"`
|
VPNAuthFile string `json:"vpn-auth-file,omitempty" yaml:"vpn-auth-file,omitempty"`
|
||||||
KubeletArg string `json:"kubelet-arg,omitempty" yaml:"kubelet-arg,omitempty"`
|
KubeletArg []string `json:"kubelet-arg,omitempty" yaml:"kubelet-arg,omitempty"`
|
||||||
KubeProxyArg string `json:"kube-proxy-arg,omitempty" yaml:"kube-proxy-arg,omitempty"`
|
KubeProxyArg []string `json:"kube-proxy-arg,omitempty" yaml:"kube-proxy-arg,omitempty"`
|
||||||
ProtectKernelDefaults bool `json:"protect-kernel-defaults,omitempty" yaml:"protect-kernel-defaults,omitempty"`
|
ProtectKernelDefaults bool `json:"protect-kernel-defaults,omitempty" yaml:"protect-kernel-defaults,omitempty"`
|
||||||
SecretsEncryption bool `yaml:"secrets-encryption,omitempty" json:"secrets-encryption,omitempty"`
|
SecretsEncryption bool `yaml:"secrets-encryption,omitempty" json:"secrets-encryption,omitempty"`
|
||||||
EnablePProf bool `yaml:"enable-pprof,omitempty" json:"enable-pprof,omitempty"`
|
EnablePProf bool `yaml:"enable-pprof,omitempty" json:"enable-pprof,omitempty"`
|
||||||
@ -120,6 +144,6 @@ type K3sServerConfig struct {
|
|||||||
EnableSELinux bool `json:"selinux,omitempty" yaml:"selinux,omitempty"`
|
EnableSELinux bool `json:"selinux,omitempty" yaml:"selinux,omitempty"`
|
||||||
LBServerPort int `json:"lb-server-port,omitempty" yaml:"lb-server-port,omitempty"`
|
LBServerPort int `json:"lb-server-port,omitempty" yaml:"lb-server-port,omitempty"`
|
||||||
DisableAgent bool `json:"disable-agent,omitempty" yaml:"disable-agent,omitempty"`
|
DisableAgent bool `json:"disable-agent,omitempty" yaml:"disable-agent,omitempty"`
|
||||||
KubeControllerArg string `json:"kube-controller-arg,omitempty" yaml:"kube-controller-arg,omitempty"`
|
KubeControllerArg []string `json:"kube-controller-arg,omitempty" yaml:"kube-controller-arg,omitempty"`
|
||||||
KubeCloudControllerArg string `json:"kube-cloud-controller-arg,omitempty" yaml:"kube-cloud-controller-arg,omitempty"`
|
KubeCloudControllerArg []string `json:"kube-cloud-controller-arg,omitempty" yaml:"kube-cloud-controller-arg,omitempty"`
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,7 @@ package provider
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"slices"
|
||||||
|
|
||||||
"net"
|
"net"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
@ -74,7 +75,7 @@ func parseOptions(cluster clusterplugin.Cluster) ([]byte, []byte, []byte) {
|
|||||||
if cluster.Role == clusterplugin.RoleControlPlane {
|
if cluster.Role == clusterplugin.RoleControlPlane {
|
||||||
k3sConfig.Server = fmt.Sprintf("https://%s:6443", cluster.ControlPlaneHost)
|
k3sConfig.Server = fmt.Sprintf("https://%s:6443", cluster.ControlPlaneHost)
|
||||||
}
|
}
|
||||||
k3sConfig.TLSSan = cluster.ControlPlaneHost
|
k3sConfig.TLSSan = []string{cluster.ControlPlaneHost}
|
||||||
// Data received from upstream contains config for both control plane and worker. Thus, for control plane,
|
// Data received from upstream contains config for both control plane and worker. Thus, for control plane,
|
||||||
// config is being filtered via unmarshal into server config.
|
// config is being filtered via unmarshal into server config.
|
||||||
var serverCfg api.K3sServerConfig
|
var serverCfg api.K3sServerConfig
|
||||||
@ -299,21 +300,21 @@ func getClusterRootPath(cluster clusterplugin.Cluster) string {
|
|||||||
func decodeOptions(in map[string]interface{}) map[string]interface{} {
|
func decodeOptions(in map[string]interface{}) map[string]interface{} {
|
||||||
out := make(map[string]interface{})
|
out := make(map[string]interface{})
|
||||||
for k, v := range in {
|
for k, v := range in {
|
||||||
out[k] = decodeOption(v)
|
out[k] = decodeOption(k, v)
|
||||||
}
|
}
|
||||||
return out
|
return out
|
||||||
}
|
}
|
||||||
|
|
||||||
func decodeOption(in interface{}) interface{} {
|
func decodeOption(k string, in interface{}) interface{} {
|
||||||
switch in := in.(type) {
|
switch in := in.(type) {
|
||||||
case []interface{}:
|
case string:
|
||||||
var out []string
|
split := strings.Split(in, ",")
|
||||||
for _, v := range in {
|
if len(split) > 1 {
|
||||||
out = append(out, decodeOption(v).(string))
|
return split
|
||||||
|
} else if slices.Contains(api.StringListKeys, k) {
|
||||||
|
return []string{in}
|
||||||
}
|
}
|
||||||
return strings.Join(out, ",")
|
return in
|
||||||
case []string:
|
|
||||||
return strings.Join(in, ",")
|
|
||||||
}
|
}
|
||||||
return in
|
return in
|
||||||
}
|
}
|
||||||
|
@ -32,7 +32,7 @@ func Test_parseOptions(t *testing.T) {
|
|||||||
ControlPlaneHost: "localhost",
|
ControlPlaneHost: "localhost",
|
||||||
Role: "init",
|
Role: "init",
|
||||||
},
|
},
|
||||||
expectedOptions: []byte(`{"tls-san":"localhost","token":"token","cluster-init":true}`),
|
expectedOptions: []byte(`{"tls-san":["localhost"],"token":"token","cluster-init":true}`),
|
||||||
expectedProxyOptions: []byte(`null`),
|
expectedProxyOptions: []byte(`null`),
|
||||||
expectedUserOptions: []byte(`{}`),
|
expectedUserOptions: []byte(`{}`),
|
||||||
},
|
},
|
||||||
@ -47,7 +47,7 @@ func Test_parseOptions(t *testing.T) {
|
|||||||
"datastore-endpoint": "localhost:2379",
|
"datastore-endpoint": "localhost:2379",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
expectedOptions: []byte(`{"cluster-init":false,"tls-san":"localhost","token":"token","datastore-endpoint":"localhost:2379"}`),
|
expectedOptions: []byte(`{"cluster-init":false,"tls-san":["localhost"],"token":"token","datastore-endpoint":"localhost:2379"}`),
|
||||||
expectedProxyOptions: []byte(`null`),
|
expectedProxyOptions: []byte(`null`),
|
||||||
expectedUserOptions: []byte(`{}`),
|
expectedUserOptions: []byte(`{}`),
|
||||||
},
|
},
|
||||||
@ -58,7 +58,7 @@ func Test_parseOptions(t *testing.T) {
|
|||||||
ControlPlaneHost: "localhost",
|
ControlPlaneHost: "localhost",
|
||||||
Role: "controlplane",
|
Role: "controlplane",
|
||||||
},
|
},
|
||||||
expectedOptions: []byte(`{"tls-san":"localhost","token":"token","server":"https://localhost:6443"}`),
|
expectedOptions: []byte(`{"tls-san":["localhost"],"token":"token","server":"https://localhost:6443"}`),
|
||||||
expectedProxyOptions: []byte(`null`),
|
expectedProxyOptions: []byte(`null`),
|
||||||
expectedUserOptions: []byte(`{}`),
|
expectedUserOptions: []byte(`{}`),
|
||||||
},
|
},
|
||||||
@ -82,7 +82,7 @@ func Test_parseOptions(t *testing.T) {
|
|||||||
Options: `disable-apiserver-lb: true
|
Options: `disable-apiserver-lb: true
|
||||||
enable-pprof: true`,
|
enable-pprof: true`,
|
||||||
},
|
},
|
||||||
expectedOptions: []byte(`{"tls-san":"localhost","token":"token","server":"https://localhost:6443"}`),
|
expectedOptions: []byte(`{"tls-san":["localhost"],"token":"token","server":"https://localhost:6443"}`),
|
||||||
expectedProxyOptions: []byte(`{"disable-apiserver-lb":true,"enable-pprof":true}`),
|
expectedProxyOptions: []byte(`{"disable-apiserver-lb":true,"enable-pprof":true}`),
|
||||||
expectedUserOptions: []byte(`{"enable-pprof":true}`),
|
expectedUserOptions: []byte(`{"enable-pprof":true}`),
|
||||||
},
|
},
|
||||||
@ -142,7 +142,7 @@ func Test_decodeOptions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: map[string]interface{}{
|
want: map[string]interface{}{
|
||||||
"test": "xyz,zyx",
|
"test": []string{"xyz", "zyx"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -153,7 +153,7 @@ func Test_decodeOptions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: map[string]interface{}{
|
want: map[string]interface{}{
|
||||||
"test": "xyz,zyx",
|
"test": []interface{}{"xyz", "zyx"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -165,23 +165,25 @@ func Test_decodeOptions(t *testing.T) {
|
|||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: map[string]interface{}{
|
want: map[string]interface{}{
|
||||||
"test": "xyz,zyx",
|
"test": []interface{}{"xyz", "zyx"},
|
||||||
"test2": "abc,cba",
|
"test2": []string{"abc", "cba"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "One list of interfaces and one list of strings",
|
name: "One string and one comma separated string",
|
||||||
args: args{
|
args: args{
|
||||||
in: map[string]interface{}{
|
in: map[string]interface{}{
|
||||||
"test": []interface{}{"xyz", "zyx"},
|
"test": "xyz,zyx",
|
||||||
"test2": []string{"abc", "cba"},
|
"test2": []string{"abc", "cba"},
|
||||||
"test3": []interface{}{[]interface{}{"lmn", "pqr"}, "fed"},
|
"test3": "xyz",
|
||||||
|
"cluster-cidr": "192.168.0.1/24",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
want: map[string]interface{}{
|
want: map[string]interface{}{
|
||||||
"test": "xyz,zyx",
|
"test": []string{"xyz", "zyx"},
|
||||||
"test2": "abc,cba",
|
"test2": []string{"abc", "cba"},
|
||||||
"test3": "lmn,pqr,fed",
|
"test3": "xyz",
|
||||||
|
"cluster-cidr": []string{"192.168.0.1/24"},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user