resources

package
v0.0.0-...-0ce3801 Latest Latest
Warning

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

Go to latest
Published: Aug 6, 2020 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const CommonServicesProductID = "068a62892a1e4db39641342e592daa25"
View Source
const CommonServicesProductName = "IBM Cloud Platform Common Services"
View Source
const CommonServicesProductVersion = "3.4.0"
View Source
const DefaultAPIKeySecretName = "icp-serviceid-apikey-secret" + ""

use concatenation so linter won't complain about "Secret" vars

View Source
const DefaultClusterIssuer = "cs-ca-clusterissuer"
View Source
const DefaultClusterName = "mycluster"
View Source
const DefaultDmImageName = "metering-data-manager"
View Source
const DefaultDmImageTag = "3.6.0"

starting with Common Services 3.4, images can be pulled by SHA or tag. run scripts/get-image-sha.sh to update operator.yaml with the SHA values. a SHA value looks like this: "sha256:nnnnnnnn" a tag value looks like this: "3.5.0".

View Source
const DefaultImageRegistry = "quay.io/opencloudio"
View Source
const DefaultPlatformOidcSecretName = "platform-oidc-credentials" + ""
View Source
const MeteringComponentName = "meteringsvc"
View Source
const MeteringDependencies = "ibm-common-services.auth-idp, mongodb, cert-manager"
View Source
const MeteringReleaseName = "metering"
View Source
const SenderDeploymentName = "metering-sender"
View Source
const VarImageSHAforDM = "IMAGE_SHA_OR_TAG_DM"

define the env vars that contain either the SHA or the tag

Variables

View Source
var ArchitectureList = []string{
	"amd64",
	"ppc64le",
	"s390x",
}
View Source
var CommonEnvVars = []corev1.EnvVar{
	{
		Name:  "NODE_TLS_REJECT_UNAUTHORIZED",
		Value: "0",
	},
}
View Source
var CommonMainVolumeMounts = []corev1.VolumeMount{
	{
		Name:      "mongodb-ca-cert",
		MountPath: "/certs/mongodb-ca",
	},
	{
		Name:      "mongodb-client-cert",
		MountPath: "/certs/mongodb-client",
	},
}
View Source
var DefaultMode int32 = 420
View Source
var DefaultStatusForCR = []string{"none"}
View Source
var FalseVar = false
View Source
var LoglevelVolumeMount = corev1.VolumeMount{
	Name:      "loglevel",
	MountPath: "/etc/config",
}
View Source
var Replica1 int32 = 1
View Source
var Seconds60 int64 = 60
View Source
var SecretCheckCmd = `set -- $SECRET_LIST; ` +
	`for secretDirName in $SECRET_DIR_LIST; do` +
	`  while true; do` +
	`    echo ` + "`date`" + `: Checking for secret $1;` +
	`    ls /sec/$secretDirName/* && break;` +
	`    echo ` + "`date`" + `: Required secret $1 not found ... try again in 30s;` +
	`    sleep 30;` +
	`  done;` +
	`  echo ` + "`date`" + `: Secret $1 found;` +
	`  shift; ` +
	`done; ` +
	`echo ` + "`date`" + `: All required secrets exist`
View Source
var SenderMainContainer = corev1.Container{
	Image:           "metering-data-manager",
	Name:            "metering-sender",
	ImagePullPolicy: corev1.PullAlways,

	VolumeMounts: []corev1.VolumeMount{
		LoglevelVolumeMount,
	},

	Env: []corev1.EnvVar{
		{
			Name:  "METERING_API_ENABLED",
			Value: "false",
		},
		{
			Name:  "HC_DM_SELFMETER_PURGER_ENABLED",
			Value: "false",
		},
		{
			Name:  "HC_DM_REPORTER2_ENABLED",
			Value: "false",
		},
		{
			Name:  "HC_DM_PURGER2_ENABLED",
			Value: "false",
		},
		{
			Name:  "HC_DM_PREAGGREGATOR_ENABLED",
			Value: "false",
		},
		{
			Name:  "HC_DM_METRICS_ENABLED",
			Value: "false",
		},
		{
			Name:  "HC_DM_READER_APIENABLED",
			Value: "false",
		},
		{
			Name:  "HC_DM_MCM_RECEIVER_ENABLED",
			Value: "false",
		},
		{
			Name:  "HC_DM_MCMREADER_ENABLED",
			Value: "false",
		},
		{
			Name:  "HC_DM_MCM_SENDER_ENABLED",
			Value: "true",
		},
	},
	LivenessProbe: &corev1.Probe{
		Handler: corev1.Handler{
			HTTPGet: &corev1.HTTPGetAction{
				Path: "/livenessProbe",
				Port: intstr.IntOrString{
					Type:   intstr.Int,
					IntVal: 3000,
				},
				Scheme: corev1.URISchemeHTTP,
			},
		},
		InitialDelaySeconds: 305,
		TimeoutSeconds:      5,
		PeriodSeconds:       300,
		SuccessThreshold:    1,
		FailureThreshold:    3,
	},
	ReadinessProbe: &corev1.Probe{
		Handler: corev1.Handler{
			HTTPGet: &corev1.HTTPGetAction{
				Path: "/readinessProbe",
				Port: intstr.IntOrString{
					Type:   intstr.Int,
					IntVal: 3000,
				},
				Scheme: corev1.URISchemeHTTP,
			},
		},
		InitialDelaySeconds: 15,
		TimeoutSeconds:      15,
		PeriodSeconds:       30,
		SuccessThreshold:    1,
		FailureThreshold:    3,
	},
	Resources: corev1.ResourceRequirements{
		Limits: map[corev1.ResourceName]resource.Quantity{
			corev1.ResourceCPU:    *cpu500,
			corev1.ResourceMemory: *memory512},
		Requests: map[corev1.ResourceName]resource.Quantity{
			corev1.ResourceCPU:    *cpu100,
			corev1.ResourceMemory: *memory128},
	},
	SecurityContext: &commonSecurityContext,
}
View Source
var SenderSecretCheckCmd = SecretCheckCmd + ";" +
	`echo ` + "`date`" + `: Further, checking for kubeConfig secret...;` +
	`node /datamanager/lib/metering_init.js kubeconfig_secretcheck `
View Source
var TrueVar = true

Functions

func AnnotationsForPod

func AnnotationsForPod() map[string]string

AnnotationsForPod returns the annotations associated with the pod being created

func BuildCommonClusterEnvVars

func BuildCommonClusterEnvVars(instanceNamespace, instanceIAMnamespace string) []corev1.EnvVar

func BuildCommonVolumes

func BuildCommonVolumes(mongoDB operatorv1alpha1.MeteringSpecMongoDB, loglevelPrefix, loglevelType string) []corev1.Volume

set loglevelType to "log4js" when building volumes for metering-mcmui. set loglevelType to "loglevel" when building volumes for any other component.

func BuildInitContainer

func BuildInitContainer(deploymentName, imageName string, envVars []corev1.EnvVar) corev1.Container

func BuildMongoDBEnvVars

func BuildMongoDBEnvVars(mongoDB operatorv1alpha1.MeteringSpecMongoDB) []corev1.EnvVar

func BuildSecretCheckContainer

func BuildSecretCheckContainer(deploymentName, imageName, checkerCommand string,
	mongoDB operatorv1alpha1.MeteringSpecMongoDB, additionalInfo *SecretCheckData) corev1.Container

checkerCommand is the command to be executed by the secret-check container. mongoDB contains the password names from the CR. additionalInfo contains info about additional secrets to check.

func BuildSenderClusterEnvVars

func BuildSenderClusterEnvVars(instanceNamespace, instanceClusterNamespace,
	instanceClusterName, hubKubeConfigSecret string) []corev1.EnvVar

func GetImageID

func GetImageID(instanceImageRegistry, instanceImageTagPostfix, defaultImageRegistry,
	imageName, envVarName, defaultImageTag string) string

GetImageID returns the ID of an operand image, either <imageName>@<SHA> or <imageName>:<tag>

func GetPodNames

func GetPodNames(pods []corev1.Pod) []string

GetPodNames returns the pod names of the array of pods passed in

func GetServiceAccountName

func GetServiceAccountName() string

GetServiceAccountName returns the service account name or default if it is not set in the environment

func IsDeploymentEqual

func IsDeploymentEqual(oldDeployment, newDeployment *appsv1.Deployment) bool

Use DeepEqual to determine if 2 deployments are equal. Check labels, replicas, pod template labels, service account names, volumes, containers, init containers, image name, volume mounts, env vars, liveness, readiness. If there are any differences, return false. Otherwise, return true. oldDeployment is the deployment that is currently running. newDeployment is what we expect the deployment to look like.

func LabelsForMetadata

func LabelsForMetadata(deploymentName string) map[string]string

returns the labels associated with the resource being created

func LabelsForPodMetadata

func LabelsForPodMetadata(deploymentName string, crType string, crName string) map[string]string

returns the labels associated with the Pod being created

func LabelsForSelector

func LabelsForSelector(deploymentName string, crType string, crName string) map[string]string

returns the labels for selecting the resources belonging to the given metering CR name

func ReconcileDeployment

func ReconcileDeployment(client client.Client, instanceNamespace, deploymentName, deploymentType string,
	newDeployment *appsv1.Deployment, needToRequeue *bool) error

Check if a Deployment already exists. If not, create a new one.

Types

type SecretCheckData

type SecretCheckData struct {
	Names        string
	Dirs         string
	VolumeMounts []corev1.VolumeMount
}

SecretCheckData contains info about additional secrets for the secret-check container. Names will be added to the SECRET_LIST env var. Dirs will be added to the SECRET_DIR_LIST env var. VolumeMounts contains the volume mounts associated with the secrets.

Jump to

Keyboard shortcuts

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