template

package
v17.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: Apache-2.0 Imports: 17 Imported by: 4

Documentation

Index

Constants

View Source
const (
	InitialClusterStateNew      = "new"
	InitialClusterStateExisting = "existing"
)
View Source
const MasterTemplate = `` /* 29836-byte string literal not displayed */
View Source
const WorkerTemplate = `` /* 16479-byte string literal not displayed */

Variables

This section is empty.

Functions

func GetIgnitionPath

func GetIgnitionPath(ignitionDir string) string

GetIgnitionPath returns path for the ignition assets based on base ignition directory and package subdirectory with assets.

func GetPackagePath

func GetPackagePath() (string, error)

GetPackagePath returns top package path for the current runtime file. For example, for /go/src/k8scloudconfig/v_4_1_0/file.go function returns /go/src/k8scloudconfig. This function used only in tests for retrieving ignition assets in runtime.

func IsComponentNotFound

func IsComponentNotFound(err error) bool

IsComponentNotFound asserts componentNotFoundError.

func IsInvalidConfig

func IsInvalidConfig(err error) bool

IsInvalidConfig asserts invalidConfigError.

func IsRetrieveRuntimeError

func IsRetrieveRuntimeError(err error) bool

IsRetrieveRuntimeError asserts retrieveRuntimeError.

func IsValidationError

func IsValidationError(err error) bool

IsValidationError asserts validationError.

func RenderAssetContent

func RenderAssetContent(assetContent string, params interface{}) ([]string, error)

func RenderFileAssetContent

func RenderFileAssetContent(assetContent string, params interface{}) (string, error)

RenderFileAssetContent returns base64 representation of the rendered assetContent.

Types

type CloudConfig

type CloudConfig struct {
	// contains filtered or unexported fields
}

func NewCloudConfig

func NewCloudConfig(config CloudConfigConfig) (*CloudConfig, error)

func (*CloudConfig) Base64

func (c *CloudConfig) Base64() string

func (*CloudConfig) ExecuteTemplate

func (c *CloudConfig) ExecuteTemplate() error

func (*CloudConfig) String

func (c *CloudConfig) String() string

type CloudConfigConfig

type CloudConfigConfig struct {
	Params   Params
	Template string
}

type Debug

type Debug struct {
	Enabled    bool
	LogsPrefix string
	LogsToken  string
}

type Etcd

type Etcd struct {
	// ClientPort allows the port for clients to be specified.
	// aws-operator sets this to the Etcd listening port so Calico on the
	// worker nodes can access via a CNAME record to the master.
	ClientPort int
	// Enabled when set to true will cause rendering master template for cluster of 3 masters. Single master otherwise.
	// Defaults to false.
	HighAvailability bool
	// InitialCluster is config which define which etcd are members of the cluster.
	// The format should look like this: `etcd1=https://etcd1.example.com:2380,etcd2=https://etcd2.example.com:2380,etcd3=https://etcd3.example.com:2380`
	// Where etcd1.example.com, etcd2.example.com, and etcd3.example.com can be either the IP or DNS of the master machine
	// where is etcd listening.
	InitialCluster string
	// Initial cluster state for the etcd cluster. Should have values either `new` or `existing`.
	InitialClusterState string
	// NodeName is the name of the current etcd cluster node.
	NodeName string
	// QuotaBackendBytes allows to set a custom value for the --quota-backend-bytes etcd flag. Defaults to 8Gb.
	QuotaBackendBytes int64
}

type Extension

type Extension interface {
	Files() ([]FileAsset, error)
	Units() ([]UnitAsset, error)
	VerbatimSections() []VerbatimSection
}

type FileAsset

type FileAsset struct {
	Metadata FileMetadata
	Content  string
}

type FileMetadata

type FileMetadata struct {
	AssetContent string
	Path         string
	Owner        Owner
	Compression  bool
	Permissions  int
}

type Files

type Files map[string]string

Files is map[string]string (k: filename, v: contents) for files that are fetched from disk and then filled with data.

func RenderFiles

func RenderFiles(filesdir string, ctx interface{}) (Files, error)

RenderFiles walks over filesdir and parses all regular files with text/template. Parsed templates are then rendered with ctx, base64 encoded and added to returned Files.

filesdir must not contain any other files than templates that can be parsed with text/template.

type Group

type Group struct {
	ID   int
	Name string
}

Group object reflects spec for ignition Group object. If both ID and name are specified, ID is preferred.

type Images

type Images struct {
	CalicoCNI                    string
	CalicoCRDInstaller           string
	Calicoctl                    string
	CalicoKubeControllers        string
	CalicoNode                   string
	CalicoTypha                  string
	Envsubst                     string
	Etcd                         string
	Hyperkube                    string
	KubeApiserver                string
	KubeControllerManager        string
	KubeScheduler                string
	KubeProxy                    string
	KubernetesAPIHealthz         string
	KubernetesNetworkSetupDocker string
	Pause                        string
}

func BuildImages

func BuildImages(registryDomain string, versions Versions) Images

type Kubernetes

type Kubernetes struct {
	Apiserver         KubernetesPodOptions
	ControllerManager KubernetesPodOptions
	Kubelet           KubernetesDockerOptions
}

type KubernetesDockerOptions

type KubernetesDockerOptions struct {
	RunExtraArgs     []string
	CommandExtraArgs []string
}

type KubernetesPodOptions

type KubernetesPodOptions struct {
	HostExtraMounts  []KubernetesPodOptionsHostMount
	CommandExtraArgs []string
	// ServiceAccountKeyFilePath is the path to the file to be used as `--service-account-key-file` in api server flags.
	// If left empty the default value '/etc/kubernetes/ssl/service-account-key.pem' is used
	ServiceAccountKeyFilePath string
	// ServiceAccountSigningKeyFilePath is the path to the file that contains the current private key of the service account token issuer. The issuer will sign issued ID tokens with this private key.
	// If left empty the default value '/etc/kubernetes/ssl/service-account-key.pem' is used
	ServiceAccountSigningKeyFilePath string
}

type KubernetesPodOptionsHostMount

type KubernetesPodOptionsHostMount struct {
	Name     string
	Path     string
	ReadOnly bool
}

type Owner

type Owner struct {
	Group Group
	User  User
}

type Params

type Params struct {
	// APIServerEncryptionKey is AES-CBC with PKCS#7 padding key to encrypt API
	// etcd data.
	APIServerEncryptionKey string
	BaseDomain             string
	Cluster                v1alpha1.Cluster
	// Debug options
	Debug Debug
	// EnableAWSCNI flag. When set to true will use AWS CNI for pod networking
	// and Calico only for network policies.
	EnableAWSCNI bool
	// AWSCNISubnetPrefixMode set to true when cluster is using Subnet Prefix mode, will remove pod limit per node.
	AWSCNISubnetPrefixMode bool
	// ControllerManagerTerminatedPodGcThreshold flag. Set the value to use for ControllerManager terminated-pod-gc-threshold flag
	ControllerManagerTerminatedPodGcThreshold int
	// EnableCronJobTimeZone flag. When set to true the `CronJobTimeZone` feature flag will be enabled.
	EnableCronJobTimeZone bool
	// force cgroups v1 on flatcar 3033.2.1 and above
	// this configuration will do reboot to ensure kernel loaded the arguments
	ForceCGroupsV1 bool
	// InTreePluginAWSUnregister flag. Disables the AWS EBS in-tree driver
	InTreePluginAWSUnregister bool
	// CalicoPolicyOnly flag. When set to true will deploy calico for network policies only.
	CalicoPolicyOnly bool
	// DisableCalico allow preventing calico installation.
	DisableCalico bool
	// DisableEncryptionAtREST flag. When set removes all manifests from the cloud
	// config related to Kubernetes encryption at REST.
	DisableEncryptionAtREST bool
	// DisableIngressControllerService flag. When set removes the manifest for
	// the Ingress Controller service. This allows us to migrate providers to
	// chart-operator independently.
	DisableIngressControllerService bool
	// DockerhubToken is an auth token used by kubelet to
	// authenticate/authorize against https://index.docker.io/v1/.
	// DisableKubeProxy allows to avoid installing kube-proxy in a cluster.
	DisableKubeProxy bool
	DockerhubToken   string
	Etcd             Etcd
	Extension        Extension
	// ExternalCloudControllerManager when set to true, it disables in-tree cloud controller manager
	// by setting `--cloud-provider` flag to `external` for api-server, kubelet and controller-manager.
	// When set to `true` it needs an external controller manager to be run as a pod in the cluster.
	ExternalCloudControllerManager bool
	// ExtraManifests allows to specify extra Kubernetes manifests in
	// /opt/k8s-addons script. The manifests are applied after calico is
	// ready.
	//
	// The general use-case is to create a manifest file with Extension and
	// then apply the manifest by adding it to ExtraManifests.
	ExtraManifests []string
	Files          Files
	// Container images used in the cloud-config templates
	Images Images
	// Kubernetes components allow the passing of extra `docker run` and
	// `command` arguments to image commands. This allows, for example,
	// the addition of cloud provider extensions.
	Kubernetes         Kubernetes
	KVMWorkerMountTags []string
	Node               v1alpha1.ClusterNode
	// Proxy environment to be configured for systemd units (docker).
	Proxy Proxy
	// RegistryMirrors to be configured for docker daemon. It should be
	// domain names only without the protocol prefix, e.g.:
	// ["giantswarm.azurecr.io"].
	RegistryMirrors []string
	SSOPublicKey    string
	Versions        Versions
}

func (*Params) Validate

func (p *Params) Validate() error

type Proxy

type Proxy struct {
	HTTP    string
	HTTPS   string
	NoProxy string
}

type UnitAsset

type UnitAsset struct {
	Metadata UnitMetadata
	Content  []string
}

type UnitMetadata

type UnitMetadata struct {
	AssetContent string
	Name         string
	Enabled      bool
}

type User

type User struct {
	ID   int
	Name string
}

User object reflects spec for ignition User object. If both ID and name are specified, ID is preferred.

type VerbatimSection

type VerbatimSection struct {
	Name    string
	Content string
}

VerbatimSection is a blob of YAML we want to add to the CloudConfig, with no variable interpolation.

type Versions

type Versions struct {
	Calico                       string
	CRITools                     string
	Etcd                         string
	Kubernetes                   string
	KubernetesAPIHealthz         string
	KubernetesNetworkSetupDocker string
}

func ExtractComponentVersions

func ExtractComponentVersions(releaseComponents []v1alpha1.ReleaseSpecComponent) (Versions, error)

Jump to

Keyboard shortcuts

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