config

package
v0.0.0-...-7132af1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2021 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// ClusterCfgTempl defines the template of cluster configuration file for the existing cluster.
	ClusterCfgTempl = template.Must(template.New("ClusterCfg").Parse(
		dedent.Dedent(`apiVersion: kubekey.kubesphere.io/v1alpha1
kind: Cluster
metadata:
  name: {{ .Options.Name }}
spec:
  hosts: 
  # You should complete the ssh information of the hosts
  {{- range .Options.Hosts }}
  - {{ . }}
  {{- end }}
  roleGroups:
    etcd:
    - SHOULD_BE_REPLACED
    master: 
    {{- range .Options.MasterGroup }}
    - {{ . }}
    {{- end }}
    worker:
    {{- range .Options.WorkerGroup }}
    - {{ . }}
    {{- end }}
  controlPlaneEndpoint:
    # If loadbalancer was used, 'address' should be set to loadbalancer's ip.
    domain: {{ .Options.ControlPlaneEndpointDomain }}
    address: {{ .Options.ControlPlaneEndpointAddress }}
    port: {{ .Options.ControlPlaneEndpointPort }}
  kubernetes:
    version: {{ .Options.KubeVersion }}
    clusterName: {{ .Options.ClusterName }}
    proxyMode: {{ .Options.ProxyMode }}
    masqueradeAll: {{ .Options.MasqueradeAll }}
    maxPods: {{ .Options.MaxPods }}
    nodeCidrMaskSize: {{ .Options.NodeCidrMaskSize }}
  network:
    plugin: {{ .Options.NetworkPlugin }}
    kubePodsCIDR: {{ .Options.PodNetworkCidr }}
    kubeServiceCIDR: {{ .Options.ServiceNetworkCidr }}
  registry:
    privateRegistry: ""

    `)))
)
View Source
var (
	// ClusterObjTempl defines the template of cluster configuration file default.
	ClusterObjTempl = template.Must(template.New("Cluster").Parse(
		dedent.Dedent(`apiVersion: kubekey.kubesphere.io/v1alpha1
kind: Cluster
metadata:
  name: {{ .Options.Name }}
spec:
  hosts:
  - {name: node1, address: 172.16.0.2, internalAddress: 172.16.0.2, user: ubuntu, password: Qcloud@123}
  - {name: node2, address: 172.16.0.3, internalAddress: 172.16.0.3, user: ubuntu, password: Qcloud@123}
  roleGroups:
    etcd:
    - node1
    master: 
    - node1
    worker:
    - node1
    - node2
  controlPlaneEndpoint:
    domain: lb.kubesphere.local
    address: ""
    port: 6443
  kubernetes:
    version: {{ .Options.KubeVersion }}
    imageRepo: kubesphere
    clusterName: cluster.local
  network:
    plugin: calico
    kubePodsCIDR: 10.233.64.0/18
    kubeServiceCIDR: 10.233.0.0/18
  registry:
    registryMirrors: []
    insecureRegistries: []
  addons: []

{{ if .Options.KubeSphereEnabled }}
{{ .Options.KubeSphereConfigMap }}
{{ end }}
    `)))
)

Functions

func AllinoneCfg

func AllinoneCfg(user *user.User, k8sVersion, ksVersion string, ksEnabled bool, logger *log.Logger) (*kubekeyapiv1alpha1.Cluster, string)

AllinoneCfg is used to generate cluster object for all-in-one mode.

func CheckConfigFileStatus

func CheckConfigFileStatus(path string)

CheckConfigFileStatus is used to check the status of cluster configuration file.

func GenerateClusterCfgStr

func GenerateClusterCfgStr(opt *OptionsCluster) (string, error)

GenerateClusterCfgStr is used to generate cluster configuration content.

func GenerateClusterObj

func GenerateClusterObj(k8sVersion, ksVersion, name, kubeconfig, clusterCfgPath string, ksEnabled, fromCluster bool) error

GenerateClusterObj is used to generate cluster configuration file

func GenerateClusterObjStr

func GenerateClusterObjStr(opt *Options) (string, error)

GenerateClusterObjStr is used to generate cluster configuration content.

func GenerateConfigFromCluster

func GenerateConfigFromCluster(cfgPath, kubeconfig, name string) error

GenerateConfigFromCluster is used to generate cluster configuration file from the existing cluster's information.

func ParseCfg

func ParseCfg(clusterCfgPath, k8sVersion, ksVersion string, ksEnabled bool) (*kubekeyapiv1alpha1.Cluster, string, error)

ParseCfg is used to parse the specified cluster configuration file.

func ParseClusterCfg

func ParseClusterCfg(clusterCfgPath, k8sVersion, ksVersion string, ksEnabled bool, logger *log.Logger) (*kubekeyapiv1alpha1.Cluster, string, error)

ParseClusterCfg is used to generate Cluster object and cluster's name.

Types

type Options

type Options struct {
	Name                string
	KubeVersion         string
	KubeSphereEnabled   bool
	KubeSphereConfigMap string
}

Options defineds the parameters of cluster configuration.

type OptionsCluster

type OptionsCluster struct {
	Name                        string
	Hosts                       []string
	MasterGroup                 []string
	WorkerGroup                 []string
	KubeVersion                 string
	ImageRepo                   string
	ClusterName                 string
	MasqueradeAll               string
	ProxyMode                   string
	MaxPods                     string
	NodeCidrMaskSize            string
	PodNetworkCidr              string
	ServiceNetworkCidr          string
	NetworkPlugin               string
	ControlPlaneEndpointDomain  string
	ControlPlaneEndpointAddress string
	ControlPlaneEndpointPort    string
}

OptionsCluster defineds the parameters of cluster configuration for the existing cluster.

func GetInfoFromCluster

func GetInfoFromCluster(config, name string) (*OptionsCluster, error)

GetInfoFromCluster is used to fetch information from the existing cluster.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL