Documentation ¶
Index ¶
- Constants
- Variables
- func CheckHealth(ctx context.Context, m *meshplayv1alpha1.Broker, client *kubernetes.Clientset) error
- func ErrConditionFalse(reason string) error
- func ErrGettingEndpoint(err error) error
- func ErrGettingResource(err error) error
- func ErrReplicasNotReady(reason string) error
- func GetEndpoint(ctx context.Context, m *meshplayv1alpha1.Broker, client *kubernetes.Clientset, ...) error
- func GetObjects(m *meshplayv1alpha1.Broker) map[string]Object
- type Object
Constants ¶
View Source
const ( ServerConfig = "server-config" AccountConfig = "account-config" ServerObject = "server-object" ServiceObject = "service-object" )
View Source
const ( ErrGettingResourceCode = "1013" ErrReplicasNotReadyCode = "1014" ErrConditionFalseCode = "1015" ErrGettingEndpointCode = "1016" )
Variables ¶
View Source
var ( MeshplayLabel = map[string]string{ "app": "meshplay", } MeshplayAnnotation = map[string]string{ "meshplay/component-type": "management-plane", } BrokerLabel = map[string]string{ "app": MeshplayLabel["app"], "component": "broker", } PrometheusAnnotation = map[string]string{ "meshplay/component-type": "management-plane", "prometheus.io/path": "/metrics", "prometheus.io/port": "7777", "prometheus.io/scrape": "true", } NatsConfigMap = &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Namespace: "meshplay", Name: "meshplay-nats-config", Labels: BrokerLabel, }, Data: map[string]string{ "nats.conf": ` # PID file shared with configuration reloader. pid_file: "/var/run/nats/nats.pid" # Monitoring http: 8222 server_name: $POD_NAME # Authorization resolver: MEMORY include "accounts/resolver.conf"`, }, } AccountsConfigMap = &corev1.ConfigMap{ ObjectMeta: metav1.ObjectMeta{ Namespace: "meshplay", Name: "meshplay-nats-accounts", Labels: BrokerLabel, }, Data: map[string]string{ "resolver.conf": ` resolver: MEMORY resolver_preload: { ACSU3Q6LTLBVLGAQUONAGXJHVNWGSKKAUA7IY5TB4Z7PLEKSR5O6JTGR: eyJ0eXAiOiJqd3QiLCJhbGciOiJlZDI1NTE5In0.eyJqdGkiOiJPRFhJSVI2Wlg1Q1AzMlFJTFczWFBENEtTSDYzUFNNSEZHUkpaT05DR1RLVVBISlRLQ0JBIiwiaWF0IjoxNTU2NjU1Njk0LCJpc3MiOiJPRFdaSjJLQVBGNzZXT1dNUENKRjZCWTRRSVBMVFVJWTRKSUJMVTRLM1lERzNHSElXQlZXQkhVWiIsIm5hbWUiOiJBIiwic3ViIjoiQUNTVTNRNkxUTEJWTEdBUVVPTkFHWEpIVk5XR1NLS0FVQTdJWTVUQjRaN1BMRUtTUjVPNkpUR1IiLCJ0eXBlIjoiYWNjb3VudCIsIm5hdHMiOnsibGltaXRzIjp7InN1YnMiOi0xLCJjb25uIjotMSwibGVhZiI6LTEsImltcG9ydHMiOi0xLCJleHBvcnRzIjotMSwiZGF0YSI6LTEsInBheWxvYWQiOi0xLCJ3aWxkY2FyZHMiOnRydWV9fX0._WW5C1triCh8a4jhyBxEZZP8RJ17pINS8qLzz-01o6zbz1uZfTOJGvwSTS6Yv2_849B9iUXSd-8kp1iMXHdoBA }`, }, } Service = &corev1.Service{ ObjectMeta: metav1.ObjectMeta{ Namespace: "meshplay", Name: "meshplay-nats", Labels: BrokerLabel, Annotations: MeshplayAnnotation, }, Spec: corev1.ServiceSpec{ Ports: []corev1.ServicePort{ { Name: "client", Port: val4222, }, { Name: "cluster", Port: val6222, }, { Name: "monitor", Port: val8222, }, { Name: "metrics", Port: val7777, }, { Name: "leafnodes", Port: val7422, }, { Name: "gateways", Port: val7522, }, }, Selector: BrokerLabel, Type: corev1.ServiceTypeLoadBalancer, }, } StatefulSet = &appsv1.StatefulSet{ ObjectMeta: metav1.ObjectMeta{ Namespace: "meshplay", Name: "meshplay-nats", Labels: BrokerLabel, Annotations: MeshplayAnnotation, }, Spec: appsv1.StatefulSetSpec{ Replicas: &val1, Selector: &metav1.LabelSelector{ MatchLabels: BrokerLabel, }, ServiceName: "meshplay-nats", Template: PodTemplate, }, } PodTemplate = corev1.PodTemplateSpec{ ObjectMeta: metav1.ObjectMeta{ Namespace: "meshplay", Name: "meshplay-nats", Labels: BrokerLabel, Annotations: PrometheusAnnotation, }, Spec: corev1.PodSpec{ ServiceAccountName: "meshplay-operator", Volumes: []corev1.Volume{ { Name: "config-volume", VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ Name: "meshplay-nats-config", }, }, }, }, { Name: "pid", VolumeSource: corev1.VolumeSource{ EmptyDir: &corev1.EmptyDirVolumeSource{}, }, }, { Name: "resolver-volume", VolumeSource: corev1.VolumeSource{ ConfigMap: &corev1.ConfigMapVolumeSource{ LocalObjectReference: corev1.LocalObjectReference{ Name: "meshplay-nats-accounts", }, }, }, }, }, ShareProcessNamespace: &valtrue, TerminationGracePeriodSeconds: &val60, Containers: []corev1.Container{ { Name: "nats", Image: "nats:2.8.2-alpine3.15", ImagePullPolicy: corev1.PullIfNotPresent, Ports: []corev1.ContainerPort{ { Name: "client", ContainerPort: val4222, }, { Name: "cluster", ContainerPort: val6222, }, { Name: "leafnodes", ContainerPort: val7422, }, { Name: "gateways", ContainerPort: val7522, }, { Name: "monitor", ContainerPort: val8222, }, { Name: "metrics", ContainerPort: val7777, }, }, Command: []string{ "nats-server", "--config", "/etc/nats-config/nats.conf", }, Env: []corev1.EnvVar{ { Name: "POD_NAME", ValueFrom: &corev1.EnvVarSource{ FieldRef: &corev1.ObjectFieldSelector{ FieldPath: "metadata.name", }, }, }, { Name: "POD_NAMESPACE", ValueFrom: &corev1.EnvVarSource{ FieldRef: &corev1.ObjectFieldSelector{ FieldPath: "metadata.namespace", }, }, }, { Name: "CLUSTER_ADVERTISE", Value: "$(POD_NAME).meshplay-nats.$(POD_NAMESPACE).svc", }, }, VolumeMounts: []corev1.VolumeMount{ { Name: "config-volume", MountPath: "/etc/nats-config", }, { Name: "pid", MountPath: "/var/run/nats", }, { Name: "resolver-volume", MountPath: "/etc/nats-config/accounts", }, }, LivenessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ HTTPGet: &corev1.HTTPGetAction{ Path: "/", Port: intstr.IntOrString{ IntVal: val8222, }, }, }, InitialDelaySeconds: 10, TimeoutSeconds: 5, }, ReadinessProbe: &corev1.Probe{ ProbeHandler: corev1.ProbeHandler{ HTTPGet: &corev1.HTTPGetAction{ Path: "/", Port: intstr.IntOrString{ IntVal: val8222, }, }, }, InitialDelaySeconds: 10, TimeoutSeconds: 5, }, Lifecycle: &corev1.Lifecycle{ PreStop: &corev1.LifecycleHandler{ Exec: &corev1.ExecAction{ Command: []string{ "/bin/sh", "-c", "nats-server -sl=ldm=/var/run/nats/nats.pid && /bin/sleep 60", }, }, }, }, }, { Name: "reloader", Image: "connecteverything/nats-server-config-reloader:0.6.0", ImagePullPolicy: corev1.PullIfNotPresent, Command: []string{ "nats-server-config-reloader", "-pid", "/var/run/nats/nats.pid", "-config", "/etc/nats-config/nats.conf", }, VolumeMounts: []corev1.VolumeMount{ { Name: "config-volume", MountPath: "/etc/nats-config", }, { Name: "pid", MountPath: "/var/run/nats", }, }, }, }, }, } )
Functions ¶
func CheckHealth ¶
func CheckHealth(ctx context.Context, m *meshplayv1alpha1.Broker, client *kubernetes.Clientset) error
func ErrConditionFalse ¶
func ErrGettingEndpoint ¶
func ErrGettingResource ¶
func ErrReplicasNotReady ¶
func GetEndpoint ¶
func GetEndpoint(ctx context.Context, m *meshplayv1alpha1.Broker, client *kubernetes.Clientset, url string) error
GetEndpoint returns those endpoints in the given service which match the selector.
func GetObjects ¶
func GetObjects(m *meshplayv1alpha1.Broker) map[string]Object
Types ¶
Click to show internal directories.
Click to hide internal directories.