|
|
|
@ -30,7 +30,7 @@ var logsEndpointRe = regexp.MustCompile(`^--logs\.(?:read|tail|write|rules)\.end |
|
|
|
|
|
|
|
|
|
// BuildGateway returns a list of k8s objects for Loki Stack Gateway
|
|
|
|
|
func BuildGateway(opts Options) ([]client.Object, error) { |
|
|
|
|
cm, sha1C, err := gatewayConfigMap(opts) |
|
|
|
|
cm, tenantSecret, sha1C, err := gatewayConfigObjs(opts) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
@ -45,7 +45,7 @@ func BuildGateway(opts Options) ([]client.Object, error) { |
|
|
|
|
return nil, err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
objs := []client.Object{cm, dpl, sa, saToken, svc, ing} |
|
|
|
|
objs := []client.Object{cm, tenantSecret, dpl, sa, saToken, svc, ing} |
|
|
|
|
|
|
|
|
|
minTLSVersion := opts.TLSProfile.MinTLSVersion |
|
|
|
|
ciphersList := opts.TLSProfile.Ciphers |
|
|
|
@ -104,10 +104,8 @@ func NewGatewayDeployment(opts Options, sha1C string) *appsv1.Deployment { |
|
|
|
|
{ |
|
|
|
|
Name: "tenants", |
|
|
|
|
VolumeSource: corev1.VolumeSource{ |
|
|
|
|
ConfigMap: &corev1.ConfigMapVolumeSource{ |
|
|
|
|
LocalObjectReference: corev1.LocalObjectReference{ |
|
|
|
|
Name: GatewayName(opts.Name), |
|
|
|
|
}, |
|
|
|
|
Secret: &corev1.SecretVolumeSource{ |
|
|
|
|
SecretName: GatewayName(opts.Name), |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
|
}, |
|
|
|
@ -349,36 +347,49 @@ func NewServiceAccountTokenSecret(opts Options) client.Object { |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// gatewayConfigMap creates a configMap for rbac.yaml and tenants.yaml
|
|
|
|
|
func gatewayConfigMap(opt Options) (*corev1.ConfigMap, string, error) { |
|
|
|
|
// gatewayConfigObjs creates a configMap for rbac.yaml and a secret for tenants.yaml
|
|
|
|
|
func gatewayConfigObjs(opt Options) (*corev1.ConfigMap, *corev1.Secret, string, error) { |
|
|
|
|
cfg := gatewayConfigOptions(opt) |
|
|
|
|
rbacConfig, tenantsConfig, regoConfig, err := gateway.Build(cfg) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, "", err |
|
|
|
|
return nil, nil, "", err |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
s := sha1.New() |
|
|
|
|
_, err = s.Write(tenantsConfig) |
|
|
|
|
if err != nil { |
|
|
|
|
return nil, "", err |
|
|
|
|
return nil, nil, "", err |
|
|
|
|
} |
|
|
|
|
sha1C := fmt.Sprintf("%x", s.Sum(nil)) |
|
|
|
|
|
|
|
|
|
return &corev1.ConfigMap{ |
|
|
|
|
TypeMeta: metav1.TypeMeta{ |
|
|
|
|
Kind: "ConfigMap", |
|
|
|
|
APIVersion: corev1.SchemeGroupVersion.String(), |
|
|
|
|
}, |
|
|
|
|
ObjectMeta: metav1.ObjectMeta{ |
|
|
|
|
Name: GatewayName(opt.Name), |
|
|
|
|
Labels: commonLabels(opt.Name), |
|
|
|
|
}, |
|
|
|
|
BinaryData: map[string][]byte{ |
|
|
|
|
gateway.LokiGatewayRbacFileName: rbacConfig, |
|
|
|
|
gateway.LokiGatewayTenantFileName: tenantsConfig, |
|
|
|
|
gateway.LokiGatewayRegoFileName: regoConfig, |
|
|
|
|
}, |
|
|
|
|
}, sha1C, nil |
|
|
|
|
TypeMeta: metav1.TypeMeta{ |
|
|
|
|
Kind: "ConfigMap", |
|
|
|
|
APIVersion: corev1.SchemeGroupVersion.String(), |
|
|
|
|
}, |
|
|
|
|
ObjectMeta: metav1.ObjectMeta{ |
|
|
|
|
Name: GatewayName(opt.Name), |
|
|
|
|
Labels: commonLabels(opt.Name), |
|
|
|
|
}, |
|
|
|
|
BinaryData: map[string][]byte{ |
|
|
|
|
gateway.LokiGatewayRbacFileName: rbacConfig, |
|
|
|
|
gateway.LokiGatewayRegoFileName: regoConfig, |
|
|
|
|
}, |
|
|
|
|
}, &corev1.Secret{ |
|
|
|
|
TypeMeta: metav1.TypeMeta{ |
|
|
|
|
Kind: "Secret", |
|
|
|
|
APIVersion: corev1.SchemeGroupVersion.String(), |
|
|
|
|
}, |
|
|
|
|
ObjectMeta: metav1.ObjectMeta{ |
|
|
|
|
Name: GatewayName(opt.Name), |
|
|
|
|
Labels: ComponentLabels(LabelGatewayComponent, opt.Name), |
|
|
|
|
Namespace: opt.Namespace, |
|
|
|
|
}, |
|
|
|
|
Data: map[string][]byte{ |
|
|
|
|
gateway.LokiGatewayTenantFileName: tenantsConfig, |
|
|
|
|
}, |
|
|
|
|
Type: corev1.SecretTypeOpaque, |
|
|
|
|
}, sha1C, nil |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// gatewayConfigOptions converts Options to gateway.Options
|
|
|
|
|