TF Harbor
Contents
Terraform Harbor 管理
provider.tf
terraform {
required_providers {
harbor = {
source = "goharbor/harbor"
version = "3.10.9"
}
}
}
# set env
# HARBOR_USERNAME
# HARBOR_PASSWORD
provider "harbor" {
url = var.harbor.url
insecure = var.harbor.insecure
}
user.tf
resource "harbor_user" "upload" {
admin = true
comment = "用于镜像上传和下载使用"
email = "tf@local.com"
full_name = "app"
username = "app"
password = "xxxxxx*****"
}
image.tf
resource "harbor_registry" "hk_harbor" {
access_id = "app"
access_secret = "xxxxxxx********"
description = "harbor hk"
endpoint_url = "https://harbor-kh.local.com"
insecure = true
name = "hk_harbor"
provider_name = "harbor"
}
replication.tf
resource "harbor_replication" "hk" {
action = "push"
deletion = false
dest_namespace = "sugar"
dest_namespace_replace = 0
enabled = true
name = "hk-sugar"
description = "sync image to hk harbor"
override = true
registry_id = harbor_registry.hk_harbor.registry_id
schedule = "event_based"
filters {
name = "sugar/*"
}
}