| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 1 | import ( |
| 2 | "encoding/base64" |
| 3 | "encoding/json" |
| 4 | "strings" |
| 5 | ) |
| 6 | |
| 7 | input: { |
| 8 | network: #Network @name(Network) |
| 9 | subdomain: string @name(Subdomain) |
| gio | efa0ed4 | 2024-06-13 12:31:43 +0400 | [diff] [blame] | 10 | sshPort: int @name(SSH Port) @role(port) |
| gio | 4ece99c | 2024-07-18 11:05:50 +0400 | [diff] [blame] | 11 | allowedNetworks: [...#Network] | *[] @name(Allowed Networks) |
| gio | 11617ac | 2024-07-15 16:09:04 +0400 | [diff] [blame] | 12 | external: bool | *false @name(External) |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 13 | |
| 14 | // TODO(gio): auto generate |
| 15 | ssKeys: #SSHKey |
| 16 | fluxKeys: #SSHKey |
| 17 | dAppKeys: #SSHKey |
| 18 | } |
| 19 | |
| 20 | name: "Dodo App" |
| 21 | namespace: "dodo-app" |
| 22 | readme: "Deploy app by pushing to Git repository" |
| 23 | description: "Deploy app by pushing to Git repository" |
| 24 | icon: "<svg xmlns='http://www.w3.org/2000/svg' width='50' height='50' viewBox='0 0 48 48'><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M2.837 27.257c3.363 2.45 11.566 3.523 12.546 1.4s.424-10.94.424-10.94s-1.763 1.192-2.302.147s.44-2.433 2.319-2.858c-1.96.05-2.221-.571-2.205-.93s.67-1.878 3.527-1.241c-1.6-.751-1.943-2.956 2.352-1.568c-1.421-.735-.36-2.825 1.649-.62c-.261-1.323 1.584-1.46 2.694.907M10.648 34.633a19 19 0 0 0-4.246.719'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M15.144 43.402c3.625-2.482 7.685-6.32 7.293-13.406s-1.6-6.368-.523-7.577s6.924-.99 10.712 3.353c.032-2.874-2.504-5.508-2.504-5.508a33 33 0 0 1 5.53.163c2.852.49 2.394 2.514 3.58 2.035s.971-3.472-.39-5.377c-1.666-2.33-3.223-2.83-6.358-2.188s-4.474.458-5.54-.587s-2.026-3.538-4.605-2.515c-2.935 1.164-4.398 2.438-3.767 5.04s2.34 4.558 2.972 6.844'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M22.001 16.552c-.925-.043-1.894.055-1.709 1.328'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M20.662 16.763c1.72 2.695 3.405 3.643 9.46 3.501'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M32.14 14.966c-1.223.879-2.18 3.781-2.496 5.307M23.1 14.908c.48 1.209 1.23.728 1.315.283a1.552 1.552 0 0 0-1.543-1.883m-.408 17.472c5.328 2.71 11.631.229 16.269-2.123c-1.176 4.572-5.911 5.585-8.916 6.107'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M29.099 37.115c4.376-.294 8.024-1.578 7.833-5.296'/><path fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round' d='M20.27 38.702c6.771 3.834 12.505.798 13.786-2.615'/><circle cx='24' cy='24' r='21.5' fill='none' stroke='currentColor' stroke-linecap='round' stroke-linejoin='round'/></svg>" |
| 25 | _domain: "\(input.subdomain).\(input.network.domain)" |
| gio | 11617ac | 2024-07-15 16:09:04 +0400 | [diff] [blame] | 26 | url: "https://\(_domain)" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 27 | |
| 28 | images: { |
| 29 | softserve: { |
| 30 | repository: "charmcli" |
| 31 | name: "soft-serve" |
| 32 | tag: "v0.7.1" |
| 33 | pullPolicy: "IfNotPresent" |
| 34 | } |
| 35 | dodoApp: { |
| 36 | repository: "giolekva" |
| 37 | name: "pcloud-installer" |
| 38 | tag: "latest" |
| 39 | pullPolicy: "Always" |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | charts: { |
| 44 | softserve: { |
| gio | f884341 | 2024-05-22 16:38:05 +0400 | [diff] [blame] | 45 | kind: "GitRepository" |
| 46 | address: "https://github.com/giolekva/pcloud.git" |
| 47 | branch: "main" |
| 48 | path: "charts/soft-serve" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 49 | } |
| 50 | dodoApp: { |
| gio | f884341 | 2024-05-22 16:38:05 +0400 | [diff] [blame] | 51 | kind: "GitRepository" |
| 52 | address: "https://github.com/giolekva/pcloud.git" |
| 53 | branch: "main" |
| 54 | path: "charts/dodo-app" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 55 | } |
| 56 | } |
| 57 | |
| gio | a60f0de | 2024-07-08 10:49:48 +0400 | [diff] [blame] | 58 | volumes: db: size: "10Gi" |
| 59 | |
| 60 | ingress: { |
| 61 | "dodo-app": { |
| gio | 11617ac | 2024-07-15 16:09:04 +0400 | [diff] [blame] | 62 | auth: { |
| 63 | if input.external { |
| 64 | enabled: false |
| 65 | } |
| 66 | if !input.external { |
| 67 | enabled: true |
| 68 | } |
| 69 | } |
| gio | a60f0de | 2024-07-08 10:49:48 +0400 | [diff] [blame] | 70 | network: input.network |
| 71 | subdomain: input.subdomain |
| 72 | service: { |
| 73 | name: "web" |
| 74 | port: name: "http" |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 79 | portForward: [#PortForward & { |
| 80 | allocator: input.network.allocatePortAddr |
| gio | efa0ed4 | 2024-06-13 12:31:43 +0400 | [diff] [blame] | 81 | reservator: input.network.reservePortAddr |
| gio | cdfa372 | 2024-06-13 20:10:14 +0400 | [diff] [blame] | 82 | deallocator: input.network.deallocatePortAddr |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 83 | sourcePort: input.sshPort |
| gio | 3e67ce1 | 2024-06-13 19:47:19 +0400 | [diff] [blame] | 84 | serviceName: "soft-serve" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 85 | targetPort: 22 |
| 86 | }] |
| 87 | |
| 88 | helm: { |
| 89 | softserve: { |
| 90 | chart: charts.softserve |
| gio | f9f0bee | 2024-06-11 20:10:05 +0400 | [diff] [blame] | 91 | info: "Installing Git server" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 92 | values: { |
| 93 | serviceType: "ClusterIP" |
| 94 | addressPool: "" |
| 95 | reservedIP: "" |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 96 | adminKey: strings.Join([input.fluxKeys.public, input.dAppKeys.public], "\n") |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 97 | privateKey: input.ssKeys.private |
| 98 | publicKey: input.ssKeys.public |
| 99 | ingress: { |
| 100 | enabled: false |
| 101 | } |
| 102 | image: { |
| 103 | repository: images.softserve.fullName |
| 104 | tag: images.softserve.tag |
| 105 | pullPolicy: images.softserve.pullPolicy |
| 106 | } |
| 107 | } |
| 108 | } |
| 109 | "dodo-app": { |
| 110 | chart: charts.dodoApp |
| gio | f9f0bee | 2024-06-11 20:10:05 +0400 | [diff] [blame] | 111 | info: "Installing supervisor" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 112 | values: { |
| 113 | image: { |
| 114 | repository: images.dodoApp.fullName |
| 115 | tag: images.dodoApp.tag |
| 116 | pullPolicy: images.dodoApp.pullPolicy |
| 117 | } |
| gio | 3a5baed | 2024-07-16 15:39:31 +0400 | [diff] [blame] | 118 | clusterRoleName: "\(release.namespace)-dodo-app" |
| gio | a60f0de | 2024-07-08 10:49:48 +0400 | [diff] [blame] | 119 | port: 8080 |
| 120 | apiPort: 8081 |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 121 | repoAddr: "soft-serve.\(release.namespace).svc.cluster.local:22" |
| 122 | sshPrivateKey: base64.Encode(null, input.dAppKeys.private) |
| gio | a60f0de | 2024-07-08 10:49:48 +0400 | [diff] [blame] | 123 | self: "api.\(release.namespace).svc.cluster.local" |
| gio | 11617ac | 2024-07-15 16:09:04 +0400 | [diff] [blame] | 124 | repoPublicAddr: "ssh://\(_domain):\(input.sshPort)" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 125 | namespace: release.namespace |
| gio | cb34ad2 | 2024-07-11 08:01:13 +0400 | [diff] [blame] | 126 | envAppManagerAddr: "http://appmanager.\(global.namespacePrefix)appmanager.svc.cluster.local" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 127 | envConfig: base64.Encode(null, json.Marshal(global)) |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 128 | gitRepoPublicKey: input.ssKeys.public |
| gio | a60f0de | 2024-07-08 10:49:48 +0400 | [diff] [blame] | 129 | persistentVolumeClaimName: volumes.db.name |
| gio | 4ece99c | 2024-07-18 11:05:50 +0400 | [diff] [blame] | 130 | allowedNetworks: strings.Join([for n in input.allowedNetworks { n.name }], ",") |
| gio | 11617ac | 2024-07-15 16:09:04 +0400 | [diff] [blame] | 131 | external: input.external |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 132 | } |
| 133 | } |
| 134 | } |
| 135 | |
| 136 | resources: { |
| 137 | "config-kustomization": { |
| 138 | apiVersion: "kustomize.toolkit.fluxcd.io/v1" |
| 139 | kind: "Kustomization" |
| 140 | metadata: { |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 141 | name: "config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 142 | namespace: release.namespace |
| 143 | } |
| 144 | spec: { |
| 145 | interval: "1m" |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 146 | path: "./" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 147 | sourceRef: { |
| 148 | kind: "GitRepository" |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 149 | name: "config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 150 | namespace: release.namespace |
| 151 | } |
| 152 | prune: true |
| 153 | } |
| 154 | } |
| 155 | "config-secret": { |
| 156 | apiVersion: "v1" |
| 157 | kind: "Secret" |
| 158 | type: "Opaque" |
| 159 | metadata: { |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 160 | name: "config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 161 | namespace: release.namespace |
| 162 | } |
| 163 | data: { |
| 164 | identity: base64.Encode(null, input.fluxKeys.private) |
| 165 | "identity.pub": base64.Encode(null, input.fluxKeys.public) |
| 166 | known_hosts: base64.Encode(null, "soft-serve.\(release.namespace).svc.cluster.local \(input.ssKeys.public)") |
| 167 | } |
| 168 | } |
| 169 | "config-source": { |
| 170 | apiVersion: "source.toolkit.fluxcd.io/v1" |
| 171 | kind: "GitRepository" |
| 172 | metadata: { |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 173 | name: "config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 174 | namespace: release.namespace |
| 175 | } |
| 176 | spec: { |
| 177 | interval: "1m0s" |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 178 | ref: branch: "master" |
| 179 | secretRef: name: "config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 180 | timeout: "60s" |
| gio | 266c04f | 2024-07-03 14:18:45 +0400 | [diff] [blame] | 181 | url: "ssh://soft-serve.\(release.namespace).svc.cluster.local:22/config" |
| gio | 0eaf271 | 2024-04-14 13:08:46 +0400 | [diff] [blame] | 182 | } |
| 183 | } |
| 184 | } |