Skip to content

Commit 440808e

Browse files
committed
Revamp OVH terraform to support k3s based setups
With our k3s based setups, terraform on OVH is primarily managing *just* the harbor setup, removing all the k8s stuff. I'd like for us to use one harbor across multiple smaller VPS instances.
1 parent 03f2572 commit 440808e

File tree

5 files changed

+157
-376
lines changed

5 files changed

+157
-376
lines changed

terraform/ovh/.terraform.lock.hcl

Lines changed: 0 additions & 64 deletions
This file was deleted.

terraform/ovh/harbor.tf

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# now configure the registry via harbor itself
2+
provider "harbor" {
3+
url = ovh_cloud_project_containerregistry.registry.url
4+
username = ovh_cloud_project_containerregistry_user.admin.login
5+
password = ovh_cloud_project_containerregistry_user.admin.password
6+
}
7+
8+
# user builds go in mybinder-builds
9+
# these are separate for easier separation of retention policies
10+
resource "harbor_project" "mybinder-builds" {
11+
name = "mybinder-builds"
12+
}
13+
14+
resource "harbor_robot_account" "builder" {
15+
name = "builder"
16+
description = "BinderHub builder: push new user images"
17+
level = "project"
18+
permissions {
19+
access {
20+
action = "push"
21+
resource = "repository"
22+
}
23+
access {
24+
action = "pull"
25+
resource = "repository"
26+
}
27+
kind = "project"
28+
namespace = harbor_project.mybinder-builds.name
29+
}
30+
}
31+
32+
resource "harbor_robot_account" "user-puller" {
33+
name = "user-puller"
34+
description = "Pull access to user images"
35+
level = "project"
36+
permissions {
37+
access {
38+
action = "pull"
39+
resource = "repository"
40+
}
41+
kind = "project"
42+
namespace = harbor_project.mybinder-builds.name
43+
}
44+
}
45+
46+
47+
resource "harbor_retention_policy" "builds" {
48+
# run retention policy on Saturday morning
49+
scope = harbor_project.mybinder-builds.id
50+
schedule = "0 0 7 * * 6"
51+
# rule {
52+
# repo_matching = "**"
53+
# tag_matching = "**"
54+
# most_recently_pulled = 1
55+
# untagged_artifacts = false
56+
# }
57+
rule {
58+
repo_matching = "**"
59+
tag_matching = "**"
60+
n_days_since_last_pull = 30
61+
untagged_artifacts = false
62+
}
63+
rule {
64+
repo_matching = "**"
65+
tag_matching = "**"
66+
n_days_since_last_push = 7
67+
untagged_artifacts = false
68+
}
69+
}
70+
71+
resource "harbor_garbage_collection" "gc" {
72+
# run garbage collection on Sunday morning
73+
# try to make sure it's not run at the same time as the retention policy
74+
schedule = "0 0 7 * * 0"
75+
delete_untagged = true
76+
}
77+
78+
# registry outputs
79+
80+
output "registry_url" {
81+
value = ovh_cloud_project_containerregistry.registry.url
82+
}
83+
84+
output "registry_admin_login" {
85+
value = ovh_cloud_project_containerregistry_user.admin.login
86+
sensitive = true
87+
}
88+
89+
output "registry_admin_password" {
90+
value = ovh_cloud_project_containerregistry_user.admin.password
91+
sensitive = true
92+
}
93+
94+
# output "registry_culler_name" {
95+
# value = harbor_user.culler.username
96+
# sensitive = true
97+
# }
98+
99+
# output "registry_culler_password" {
100+
# value = harbor_user.culler.password
101+
# sensitive = true
102+
# }
103+
104+
output "registry_builder_name" {
105+
value = harbor_robot_account.builder.full_name
106+
sensitive = true
107+
}
108+
109+
output "registry_builder_token" {
110+
value = harbor_robot_account.builder.secret
111+
sensitive = true
112+
}
113+
114+
output "registry_user_puller_name" {
115+
value = harbor_robot_account.user-puller.full_name
116+
sensitive = true
117+
}
118+
output "registry_user_puller_token" {
119+
value = harbor_robot_account.user-puller.secret
120+
sensitive = true
121+
}

0 commit comments

Comments
 (0)