-
Notifications
You must be signed in to change notification settings - Fork 1
/
Secrets.ts
73 lines (63 loc) · 1.82 KB
/
Secrets.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import * as k8s from "@pulumi/kubernetes";
import {Htpasswd, HtpasswdAlgorithm} from "pulumi-htpasswd";
import {Namespace, Secret} from "@pulumi/kubernetes/core/v1";
import * as pulumi from "@pulumi/pulumi"
export function createGitlabSecret(username: string, token: string,name:string, namespace: Namespace): k8s.core.v1.Secret {
let secretData = {
"auths":
{
"registry.gitlab.com":
{"auth": Buffer.from(username + ":" + token).toString('base64')}
}
};
let encodedSecret = Buffer.from(JSON.stringify(secretData)).toString('base64')
const pullSecretName = pulumi.interpolate `gitlab-pull-secret-${namespace.metadata.name}`;
return new k8s.core.v1.Secret(name, {
metadata: {
name: pullSecretName,
namespace: namespace.metadata.name,
},
type: "kubernetes.io/dockerconfigjson",
data: {
".dockerconfigjson": encodedSecret
}
});
}
export function createEtcdSecret(rootPassword: string, namespace: Namespace) {
return new k8s.core.v1.Secret("etcd", {
metadata: {
name: "etcd",
namespace: namespace.metadata.name
},
stringData: {
"root-password": rootPassword
}
})
}
export function createDbSecret(user: string, password: string, name: string, namespace: Namespace) {
return new k8s.core.v1.Secret(name, {
metadata: {
name: name,
namespace: namespace.metadata.name
},
stringData: {
"user": user,
"password": password
}
})
}
export function createMiddleware(secret: Secret) {
return new k8s.apiextensions.CustomResource("middleware-ba", {
apiVersion: "traefik.containo.us/v1alpha1",
kind: "Middleware",
metadata: {
name: "basic-auth",
namespace: "kube-system"
},
spec: {
basicAuth: {
secret: secret.metadata.name
}
}
})
}