File tree Expand file tree Collapse file tree 8 files changed +143
-0
lines changed
Expand file tree Collapse file tree 8 files changed +143
-0
lines changed Original file line number Diff line number Diff line change 1+ name : registry
2+ description : |
3+ An authenticated docker registry running in Digitalocean.
4+ variables :
5+ digitalocean_token :
6+ sensitive : true
7+ type : string
8+ optional : false
9+ description : " A Digitalocean API token with write permission. https://docs.digitalocean.com/reference/api/create-personal-access-token/"
10+ digitalocean_domain :
11+ sensitive : true
12+ type : string
13+ optional : false
14+ description : " The domain to use for the registry host."
15+ registry_host :
16+ type : string
17+ readOnly : true
18+ description : " host the configured registry can be accessed at"
19+ username :
20+ type : string
21+ readOnly : true
22+ description : " username for registry authentication"
23+ password :
24+ type : string
25+ readOnly : true
26+ description : " password for registry authentication"
27+ commands :
28+ - module : main
29+ - command : /opt/corral/install.sh
30+ node_pools :
31+ - registry
Original file line number Diff line number Diff line change 1+ version : 0.1
2+ log :
3+ accesslog :
4+ disabled : true
5+ level : info
6+ formatter : text
7+ fields :
8+ service : registry
9+ environment : staging
10+ storage :
11+ filesystem :
12+ rootdirectory : /var/lib/registry
13+ maxthreads : 100
14+ delete :
15+ enabled : false
16+ redirect :
17+ disable : false
18+ auth :
19+ htpasswd :
20+ realm : basic-realm
21+ path : /etc/docker/registry/htpasswd
22+ http :
23+ addr : 0.0.0.0:443
24+ host : https://HOSTNAME
25+ tls :
26+ certificate : /etc/docker/registry/ssl/registry.crt
27+ key : /etc/docker/registry/ssl/registry.key
28+ headers :
29+ X-Content-Type-Options : [nosniff]
30+ http2 :
31+ disabled : false
32+
Original file line number Diff line number Diff line change 1+ [Unit]
2+ Description =Docker Registry
3+ After =network.target
4+ StartLimitIntervalSec =0
5+ [Service]
6+ Type =simple
7+ Restart =always
8+ RestartSec =1
9+ User =root
10+ ExecStart =/usr/local/bin/registry serve /etc/docker/registry/config.yml
11+
12+ [Install]
13+ WantedBy =multi-user.target
Original file line number Diff line number Diff line change 1+ variable "corral_name" {} // name of the corral being created
2+ variable "corral_user_id" {} // how the user is identified (usually github username)
3+ variable "corral_user_public_key" {} // the users public key
4+ variable "corral_public_key" {} // The corrals public key. This should be installed on every node.
5+ variable "corral_private_key" {} // The corrals private key.
6+
7+ // Package
8+ variable "digitalocean_token" {}
9+ variable "digitalocean_domain" {}
Original file line number Diff line number Diff line change 1+ terraform {
2+ required_version = " >= 0.13"
3+ required_providers {
4+ digitalocean = {
5+ source = " digitalocean/digitalocean"
6+ version = " ~> 2.0"
7+ }
8+ }
9+ }
10+
11+ provider "random" {}
12+ provider "digitalocean" {
13+ token = var. digitalocean_token
14+ }
15+
16+ // it is best practice to distinguish an environment with a random id to avoid collisions
17+ resource "random_id" "registry_id" {
18+ byte_length = 6
19+ }
20+
21+ // we will use the corral public key to get access to nodes to provision them later
22+ resource "digitalocean_ssh_key" "corral_key" {
23+ name = " ${ var . corral_user_id } -${ random_id . registry_id . hex } "
24+ public_key = var. corral_public_key
25+ }
26+
27+ resource "digitalocean_droplet" "registry" {
28+ count = 1
29+
30+ name = " ${ var . corral_user_id } -${ random_id . registry_id . hex } -registry"
31+ image = " ubuntu-20-04-x64"
32+ region = " sfo3"
33+ size = " s-1vcpu-2gb"
34+ tags = [var . corral_user_id , random_id . registry_id . hex ] // when possible resources should be marked with the associated corral
35+ ssh_keys = [digitalocean_ssh_key . corral_key . id ]
36+ }
37+
38+ resource "digitalocean_record" "registry" {
39+ domain = var. digitalocean_domain
40+ name = random_id. registry_id . hex
41+ type = " A"
42+ value = digitalocean_droplet. registry [0 ]. ipv4_address
43+ }
Original file line number Diff line number Diff line change 1+ output "corral_node_pools" {
2+ value = {
3+ registry = [
4+ for droplet in digitalocean_droplet . registry : {
5+ name = droplet.name // unique name of node
6+ user = " root" // ssh username
7+ address = droplet.ipv4_address // address of ssh host
8+ }
9+ ]
10+ }
11+ }
12+
13+ output "registry_host" {
14+ value = join (" ." , [digitalocean_record . registry . name , digitalocean_record . registry . domain ])
15+ }
You can’t perform that action at this time.
0 commit comments