-
Notifications
You must be signed in to change notification settings - Fork 1
/
Program.fs
133 lines (122 loc) · 4.66 KB
/
Program.fs
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
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
open Fubernetes.Configuration
open Fubernetes.Resources
let createSimpleSecret () =
let clusterIpService =
new Service.ClusterIPService(
{ Name = "svc-clusterip-01"
Namespace = "default"
Selector = [ ("app", "nginx"); ("network", "main-svc") ]
Ports =
[ { Name = "tcp-port"
Protocol = ServiceShared.KubernetesProtocol.TCP
Port = 8000
TargetPort = 8080 }
{ Name = "udp-port"
Protocol = ServiceShared.KubernetesProtocol.UDP
Port = 8001
TargetPort = 8081 } ] }
)
let nodePortService =
new Service.NodePortService(
{ Name = "svc-nodeport-01"
Namespace = "default"
Selector = [ ("app", "nginx"); ("network", "main-svc") ]
Ports =
[ { Name = "tcp-port"
Protocol = ServiceShared.KubernetesProtocol.TCP
Port = 8000
TargetPort = 8080
NodePort = None }
{ Name = "udp-port"
Protocol = ServiceShared.KubernetesProtocol.UDP
Port = 8001
TargetPort = 8081
NodePort = Some 30071 } ] }
)
let headlessService =
new Service.HeadlessService(
{ Name = "svc-headless-01"
Namespace = "default"
Selector = Some [ ("app", "nginx"); ("network", "main-svc") ]
Ports =
[ { Name = "tcp-port"
Protocol = ServiceShared.KubernetesProtocol.TCP
Port = 8000
TargetPort = 8080 } ] }
)
let headlessServiceWithoutSelector =
new Service.HeadlessService(
{ Name = "svc-headless-01"
Namespace = "default"
Selector = None
Ports =
[ { Name = "tcp-port"
Protocol = ServiceShared.KubernetesProtocol.TCP
Port = 8000
TargetPort = 8080 } ] }
)
let opaqueSecret =
new Secret.OpaqueSecret(
{ Name = "secret-01"
Namespace = "default"
Data = [ ("key1", "value1"); ("key2", "value2"); ("key3", "value3") ] }
)
let podTest =
new Deployment.Pod(
{ Name = "container"
Image = "nginx"
ImagePullPolicy = Deployment.ImagePullPolicy.Always
Command = Some "#!/bin/bash"
Arguments = Some [ "apt"; "update" ]
Resources =
Some
{ RequestMemory = 1024.
RequestCPU = 250.
LimitMemory = 2048.
LimitCPU = 500. }
ContainerPort = Some 8080
VolumeMount =
Some
[ { Name = "testVolume1"
MountPath = "/var/"
ReadOnly = None }
{ Name = "testVolume2"
MountPath = "/var/"
ReadOnly = Some true } ]
Env =
Some
[ Deployment.EnvType.Simple
{ Name = "hostname"
Value = "localhost" }
Deployment.EnvType.Secret
{ Name = "password"
SecretName = "database-secrets"
SecretKey = "db-pwd" } ]
ImagePullSecrets = None
Volumes =
Some
[ Deployment.VolumeType.VolumeFromPVC
{ Name = "cache-volume"
ClaimName = "cache-volume-pvc" }
Deployment.VolumeType.VolumeFromSecretProviderClass
{ Name = "secrets-store"
Driver = "secrets-csi"
ReadOnly = true
SecretProviderClassName = "my-secrets-csi" } ] }
)
let resourceList =
[ opaqueSecret.toYamlBuffer ()
clusterIpService.toYamlBuffer ()
nodePortService.toYamlBuffer ()
headlessService.toYamlBuffer ()
headlessServiceWithoutSelector.toYamlBuffer ()
podTest.toYamlBuffer () ]
let outPath = "./prod/application.yml"
let config: Configuration =
{ OutPath = outPath
Resources = resourceList }
createOutPathAndBuildYaml (config)
[<EntryPoint>]
let main argv =
createSimpleSecret ()
0 // return an integer exit code