controllers

package
v0.7.12 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2023 License: Apache-2.0 Imports: 33 Imported by: 0

Documentation

Index

Constants

View Source
const (

	// WorkingVolumeMountPath is the mount path for working volume
	WorkingVolumeMountPath = "/data"
	// InputTFConfigurationVolumeName is the volume name for input Terraform Configuration
	InputTFConfigurationVolumeName = "tf-input-configuration"
	// BackendVolumeName is the volume name for Terraform backend
	BackendVolumeName = "tf-backend"
	// InputTFConfigurationVolumeMountPath is the volume mount path for input Terraform Configuration
	InputTFConfigurationVolumeMountPath = "/opt/tf-configuration"
	// BackendVolumeMountPath is the volume mount path for Terraform backend
	BackendVolumeMountPath = "/opt/tf-backend"

	// GitAuthConfigVolumeName is the volume name for git auth configurtaion
	GitAuthConfigVolumeName = "git-auth-configuration"
	// GitAuthConfigVolumeMountPath is the volume mount path for git auth configurtaion
	GitAuthConfigVolumeMountPath = "/root/.ssh"
	// TerraformCredentialsConfigVolumeName is the volume name for terraform auth configurtaion
	TerraformCredentialsConfigVolumeName = "terraform-credentials-configuration"
	// TerraformCredentialsConfigVolumeMountPath is the volume mount path for terraform auth configurtaion
	TerraformCredentialsConfigVolumeMountPath = "/root/.terraform.d"
	// TerraformRCConfigVolumeName is the volume name of the terraform registry configuration
	TerraformRCConfigVolumeName = "terraform-rc-configuration"
	// TerraformRCConfigVolumeMountPath is the volume mount path for registry configuration
	TerraformRCConfigVolumeMountPath = "/root"
	// TerraformCredentialsHelperConfigVolumeName is the volume name for terraform auth configurtaion
	TerraformCredentialsHelperConfigVolumeName = "terraform-credentials-helper-configuration"
	// TerraformCredentialsHelperConfigVolumeMountPath is the volume mount path for terraform auth configurtaion
	TerraformCredentialsHelperConfigVolumeMountPath = "/root/.terraform.d/plugins"
)
View Source
const (
	// TFInputConfigMapName is the CM name for Terraform Input Configuration
	TFInputConfigMapName = "tf-%s"
	// TFVariableSecret is the Secret name for variables, including credentials from Provider
	TFVariableSecret = "variable-%s"
)
View Source
const (

	// ClusterRoleName is the name of the ClusterRole for Terraform Job
	ClusterRoleName = "tf-executor-clusterrole"
	// ServiceAccountName is the name of the ServiceAccount for Terraform Job
	ServiceAccountName = "tf-executor-service-account"
)
View Source
const (
	GitCredsKnownHosts = "known_hosts"
	// Terraform credentials
	TerraformCredentials = "credentials.tfrc.json"
	// Terraform Registry Configuration
	TerraformRegistryConfig = ".terraformrc"
)

Variables

This section is empty.

Functions

func GetSecretOrConfigMap added in v0.7.9

func GetSecretOrConfigMap(ctx context.Context, k8sClient client.Client, isSecret bool, ref *v1.SecretReference, neededKeys []string, errKey string) (metav1.Object, error)

Types

type ConfigurationReconciler

type ConfigurationReconciler struct {
	client.Client
	Log                 logr.Logger
	ControllerNamespace string
	ProviderName        string
	Scheme              *runtime.Scheme
}

ConfigurationReconciler reconciles a Configuration object.

func (*ConfigurationReconciler) Reconcile

func (r *ConfigurationReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile will reconcile periodically

func (*ConfigurationReconciler) SetupWithManager

func (r *ConfigurationReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager setups with a manager

type LegacySubResources added in v0.7.5

type LegacySubResources struct {
	// Namespace is the namespace of the Configuration, also the namespace of the sub-resources.
	Namespace           string
	ApplyJobName        string
	DestroyJobName      string
	ConfigurationCMName string
	VariableSecretName  string
}

LegacySubResources if user specify ControllerNamespace when re-staring controller, there are some sub-resources like Secret and ConfigMap that are in the namespace of the Configuration. We need to GC these sub-resources when Configuration is deleted.

type ProviderReconciler

type ProviderReconciler struct {
	client.Client
	Log    logr.Logger
	Scheme *runtime.Scheme
}

ProviderReconciler reconciles a Provider object

func (*ProviderReconciler) Reconcile

func (r *ProviderReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error)

Reconcile will reconcile periodically

func (*ProviderReconciler) SetupWithManager

func (r *ProviderReconciler) SetupWithManager(mgr ctrl.Manager) error

SetupWithManager setups with a manager

type ResourceQuota added in v0.7.5

type ResourceQuota struct {
	ResourcesLimitsCPU              string
	ResourcesLimitsCPUQuantity      resource.Quantity
	ResourcesLimitsMemory           string
	ResourcesLimitsMemoryQuantity   resource.Quantity
	ResourcesRequestsCPU            string
	ResourcesRequestsCPUQuantity    resource.Quantity
	ResourcesRequestsMemory         string
	ResourcesRequestsMemoryQuantity resource.Quantity
}

type TFConfigurationMeta added in v0.2.0

type TFConfigurationMeta struct {
	Name                                         string
	Namespace                                    string
	ControllerNamespace                          string
	ConfigurationType                            types.ConfigurationType
	CompleteConfiguration                        string
	RemoteGit                                    string
	RemoteGitPath                                string
	ConfigurationChanged                         bool
	EnvChanged                                   bool
	ConfigurationCMName                          string
	ApplyJobName                                 string
	DestroyJobName                               string
	Envs                                         []v1.EnvVar
	ProviderReference                            *crossplane.Reference
	VariableSecretName                           string
	VariableSecretData                           map[string][]byte
	DeleteResource                               bool
	Region                                       string
	Credentials                                  map[string]string
	JobEnv                                       map[string]interface{}
	GitCredentialsSecretReference                *v1.SecretReference
	TerraformCredentialsSecretReference          *v1.SecretReference
	TerraformRCConfigMapReference                *v1.SecretReference
	TerraformCredentialsHelperConfigMapReference *v1.SecretReference

	Backend backend.Backend
	// JobNodeSelector Expose the node selector of job to the controller level
	JobNodeSelector map[string]string

	// TerraformImage is the Terraform image which can run `terraform init/plan/apply`
	TerraformImage string
	BusyboxImage   string
	GitImage       string

	// BackoffLimit specifies the number of retries to mark the Job as failed
	BackoffLimit int32

	// ResourceQuota series Variables are for Setting Compute Resources required by this container
	ResourceQuota ResourceQuota

	LegacySubResources    LegacySubResources
	ControllerNSSpecified bool

	K8sClient client.Client
}

TFConfigurationMeta is all the metadata of a Configuration

func (*TFConfigurationMeta) CheckWhetherConfigurationChanges added in v0.2.7

func (meta *TFConfigurationMeta) CheckWhetherConfigurationChanges(ctx context.Context, k8sClient client.Client, configurationType types.ConfigurationType) error

CheckWhetherConfigurationChanges will check whether configuration is changed

func (*TFConfigurationMeta) KeepLegacySubResourceMetas added in v0.7.5

func (meta *TFConfigurationMeta) KeepLegacySubResourceMetas()

func (*TFConfigurationMeta) RenderConfiguration added in v0.7.5

func (meta *TFConfigurationMeta) RenderConfiguration(configuration *v1beta2.Configuration, configurationType types.ConfigurationType) (string, backend.Backend, error)

RenderConfiguration will compose the Terraform configuration with hcl/json and backend

type TFState

type TFState struct {
	Outputs map[string]TfStateProperty `json:"outputs"`
}

TFState is Terraform State

type TerraformExecutionType

type TerraformExecutionType string

TerraformExecutionType is the type for Terraform execution

const (
	// TerraformApply is the name to mark `terraform apply`
	TerraformApply TerraformExecutionType = "apply"
	// TerraformDestroy is the name to mark `terraform destroy`
	TerraformDestroy TerraformExecutionType = "destroy"
)

type TfStateProperty added in v0.4.1

type TfStateProperty struct {
	Value interface{} `json:"value,omitempty"`
	Type  interface{} `json:"type,omitempty"`
}

TfStateProperty is the tf state property for an output

func (*TfStateProperty) ToProperty added in v0.4.1

func (tp *TfStateProperty) ToProperty() (v1beta2.Property, error)

ToProperty converts TfStateProperty type to Property

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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