-
Notifications
You must be signed in to change notification settings - Fork 100
/
Copy pathsqldb-recipe.bicep
112 lines (106 loc) · 2.49 KB
/
sqldb-recipe.bicep
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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
extension kubernetes with {
kubeConfig: ''
namespace: context.runtime.kubernetes.namespace
} as kubernetes
param context object
@description('Specifies the SQL username.')
param username string
@description('Specifies the SQL password.')
@secure()
param password string
resource sql 'apps/Deployment@v1' = {
metadata: {
name: 'sql-${uniqueString(context.resource.id)}'
}
spec: {
replicas: 1
selector: {
matchLabels: {
app: 'sql-app'
resource: context.resource.name
}
}
template: {
metadata: {
labels: {
app: 'sql-app'
resource: context.resource.name
}
}
spec: {
containers: [
{
name: 'sql'
image: 'mcr.microsoft.com/mssql/server:2022-latest'
env: [
{
name: 'MSSQL_SA_PASSWORD'
value: password
}
{
name: 'MSSQL_SA_USERNAME'
value: username
}
{
name: 'ACCEPT_EULA'
value: 'Y'
}
]
resources: {
requests: {
cpu: '1200m'
memory: '2048Mi'
}
limits: {
cpu: '1500m'
memory: '4096Mi'
}
}
ports: [
{
containerPort: 1433
}
]
}
]
}
}
}
}
@description('Configure back-end service')
resource svc 'core/Service@v1' = {
metadata: {
name: 'sql-${uniqueString(context.resource.id)}'
}
spec: {
type: 'ClusterIP'
ports: [
{
port: 1433
}
]
selector: {
app: 'sql-app'
resource: context.resource.name
}
}
}
output result object = {
// This workaround is needed because the deployment engine omits Kubernetes resources from its output.
//
// Once this gap is addressed, users won't need to do this.
resources: [
'/planes/kubernetes/local/namespaces/${svc.metadata.namespace}/providers/core/Service/${svc.metadata.name}'
'/planes/kubernetes/local/namespaces/${sql.metadata.namespace}/providers/apps/Deployment/${sql.metadata.name}'
]
values: {
server: '${svc.metadata.name}.${svc.metadata.namespace}.svc.cluster.local'
database: 'master'
port: 1433
username: username
}
secrets: {
#disable-next-line outputs-should-not-contain-secrets
password: password
}
}