Skip to content

Commit 3ac6f7c

Browse files
committed
Add new docker_registry.server to replace address and port
1 parent 2af4404 commit 3ac6f7c

19 files changed

+56
-81
lines changed

ansible/group_vars/all.yaml

-1
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,6 @@ etcd_networking_cluster_ip_list: "{% for host in groups['etcd'] %}https://{{ hos
234234
etcd_k8s_cluster_ip_list: "{% for host in groups['etcd'] %}https://{{ host }}:{{ etcd_k8s_client_port }}{% if not loop.last %},{% endif %}{% endfor %}"
235235

236236
#===============================================================================
237-
docker_registry_full_url: "{{ docker_registry_address }}:{{ docker_registry_port }}"
238237
load_private_images: "{{ configure_docker_with_private_registry is defined and configure_docker_with_private_registry|bool == true and disconnected_installation is defined and disconnected_installation|bool == true }}"
239238

240239
official_versioned_images:

docs/container-registry.md

+2-4
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,8 @@ in the plan file.
99
## Configuring KET
1010
The following information must be provided in the plan file to use an internal
1111
image registry:
12-
* `address`: The hostname or IP address of the registry. This must be reachable from
12+
* `server`: The hostname or IP address of the registry and the port. This must be reachable from
1313
all the nodes in the cluster.
14-
* `port`: The port number on which the registry is listening.
1514
* `CA`: The absolute path to the certificate that should be trusted when connecting
1615
to the registry. This is optional. When set, KET will configure the docker daemon
1716
on all nodes to trust this certificate.
@@ -20,8 +19,7 @@ Sample:
2019
```
2120
# plan file
2221
docker_registry:
23-
address: registry.example.com
24-
port: 8443
22+
server: registry.example.com:8443
2523
CA: /certs/ca.rt
2624
```
2725

docs/plan-file-reference.md

+15-4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,9 @@
4141
* [block_device](#dockerstoragedirect_lvmblock_device)
4242
* [enable_deferred_deletion](#dockerstoragedirect_lvmenable_deferred_deletion)
4343
* [docker_registry](#docker_registry)
44-
* [address](#docker_registryaddress)
45-
* [port](#docker_registryport)
44+
* [server](#docker_registryserver)
45+
* [address _(deprecated)_](#docker_registryaddress-deprecated)
46+
* [port _(deprecated)_](#docker_registryport-deprecated)
4647
* [CA](#docker_registryCA)
4748
* [username](#docker_registryusername)
4849
* [password](#docker_registrypassword)
@@ -456,7 +457,17 @@
456457

457458
Docker registry configuration
458459

459-
### docker_registry.address
460+
### docker_registry.server
461+
462+
The hostname or IP address and port of a private container image registry. Do not include http or https. When performing a disconnected installation, this registry will be used to fetch all the required container images.
463+
464+
| | |
465+
|----------|-----------------|
466+
| **Kind** | string |
467+
| **Required** | No |
468+
| **Default** | ` ` |
469+
470+
### docker_registry.address _(deprecated)_
460471

461472
The hostname or IP address of a private container image registry. When performing a disconnected installation, this registry will be used to fetch all the required container images.
462473

@@ -466,7 +477,7 @@
466477
| **Required** | No |
467478
| **Default** | ` ` |
468479

469-
### docker_registry.port
480+
### docker_registry.port _(deprecated)_
470481

471482
The port on which the private container image registry is listening on.
472483

docs/upgrade/v1.6.0/disconnected-upgrade.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,8 @@ by KET.
4242

4343
If you want to continue using the registry that was deployed by KET, you must
4444
set the plan file fields to the following values:
45-
* `docker_registry.address`: The hostname or IP of the first master node. This
45+
* `docker_registry.server`: The hostname or IP of the first master node and port 8443 (This is the port that KET used when deploying the registry during the (installation of your cluster). This
4646
is where KET deployed the registry during the installation of your cluster.
47-
* `docker_registry.port`: 8443 (This is the port that KET used when deploying
48-
the registry during the (installation of your cluster)
4947
* `docker_registry.CA`: Absolute path to the certificate authority located in
5048
`generated/keys/ca.pem`
5149

@@ -54,8 +52,8 @@ must configure docker on the node where you are running the command to trust the
5452
certificate authority generated by KET. The way to configure this in docker
5553
depends on the operating system. If you are seeding the registry from a Linux
5654
machine, you must copy the `generated/keys/ca.pem` certificate to
57-
`/etc/docker/certs.d/${docker_registry.address}:8443/ca.crt`. For example, if
58-
the `docker_registry.address` field is set to `registry.example.com`, you would
55+
`/etc/docker/certs.d/${docker_registry.server}/ca.crt`. For example, if
56+
the `docker_registry.server` field is set to `registry.example.com:8443`, you would
5957
copy the CA to `/etc/docker/certs.d/registry.example.com:8443/ca.crt`. See the
6058
[official docker documentation](https://docs.docker.com/registry/insecure/#use-self-signed-certificates)
6159
for more information about using a registry with a self-signed certificate.

integration/disconnected_install_test.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ var _ = Describe("disconnected installation", func() {
6363
disconnectedInstallation: true,
6464
modifyHostsFiles: true,
6565
dockerRegistryCAPath: caFile,
66-
dockerRegistryIP: repoNode.PrivateIP,
67-
dockerRegistryPort: dockerRegistryPort,
66+
dockerRegistryServer: fmt.Sprintf("%s:%d", repoNode.PrivateIP, dockerRegistryPort),
6867
dockerRegistryUsername: "kismaticuser",
6968
dockerRegistryPassword: "kismaticpassword",
7069
}
@@ -120,8 +119,7 @@ var _ = Describe("disconnected installation", func() {
120119
disconnectedInstallation: true,
121120
modifyHostsFiles: true,
122121
dockerRegistryCAPath: caFile,
123-
dockerRegistryIP: repoNode.PrivateIP,
124-
dockerRegistryPort: dockerRegistryPort,
122+
dockerRegistryServer: fmt.Sprintf("%s:%d", repoNode.PrivateIP, dockerRegistryPort),
125123
dockerRegistryUsername: "kismaticuser",
126124
dockerRegistryPassword: "kismaticpassword",
127125
}

integration/docker_registry_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package integration
22

33
import (
4+
"fmt"
45
"os"
56

67
. "github.com/onsi/ginkgo"
@@ -22,8 +23,7 @@ var _ = Describe("kismatic docker registry feature", func() {
2223
Expect(err).ToNot(HaveOccurred())
2324
opts := installOptions{
2425
dockerRegistryCAPath: caFile,
25-
dockerRegistryIP: nodes.etcd[1].PrivateIP,
26-
dockerRegistryPort: dockerRegistryPort,
26+
dockerRegistryServer: fmt.Sprintf("%s:%d", nodes.etcd[1].PrivateIP, dockerRegistryPort),
2727
dockerRegistryUsername: "kismaticuser",
2828
dockerRegistryPassword: "kismaticpassword",
2929
}

integration/install.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ func GetSSHKeyFile() (string, error) {
3131
type installOptions struct {
3232
disablePackageInstallation bool
3333
disconnectedInstallation bool
34-
dockerRegistryIP string
35-
dockerRegistryPort int
34+
dockerRegistryServer string
3635
dockerRegistryCAPath string
3736
dockerRegistryUsername string
3837
dockerRegistryPassword string
@@ -96,8 +95,7 @@ func buildPlan(nodes provisionedNodes, installOpts installOptions, sshKey string
9695
SSHKeyFile: sshKey,
9796
SSHUser: sshUser,
9897
DockerRegistryCAPath: installOpts.dockerRegistryCAPath,
99-
DockerRegistryIP: installOpts.dockerRegistryIP,
100-
DockerRegistryPort: installOpts.dockerRegistryPort,
98+
DockerRegistryServer: installOpts.dockerRegistryServer,
10199
DockerRegistryUsername: installOpts.dockerRegistryUsername,
102100
DockerRegistryPassword: installOpts.dockerRegistryPassword,
103101
ModifyHostsFiles: installOpts.modifyHostsFiles,

integration/plan_patterns.go

+2-4
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,7 @@ type PlanAWS struct {
1818
HomeDirectory string
1919
DisablePackageInstallation bool
2020
DisconnectedInstallation bool
21-
DockerRegistryIP string
22-
DockerRegistryPort int
21+
DockerRegistryServer string
2322
DockerRegistryCAPath string
2423
DockerRegistryUsername string
2524
DockerRegistryPassword string
@@ -82,8 +81,7 @@ docker:
8281
block_device: "/dev/xvdb"
8382
enable_deferred_deletion: false{{end}}
8483
docker_registry:
85-
address: {{.DockerRegistryIP}}
86-
port: {{.DockerRegistryPort}}
84+
server: {{.DockerRegistryServer}}
8785
CA: {{.DockerRegistryCAPath}}
8886
username: {{.DockerRegistryUsername}}
8987
password: {{.DockerRegistryPassword}}

integration/upgrade_test.go

+4-8
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,7 @@ var _ = Describe("Upgrade", func() {
156156
disconnectedInstallation: true,
157157
modifyHostsFiles: true,
158158
dockerRegistryCAPath: caFile,
159-
dockerRegistryIP: repoNode.PrivateIP,
160-
dockerRegistryPort: dockerRegistryPort,
159+
dockerRegistryServer: fmt.Sprintf("%s:%d", repoNode.PrivateIP, dockerRegistryPort),
161160
dockerRegistryUsername: "kismaticuser",
162161
dockerRegistryPassword: "kismaticpassword",
163162
}
@@ -224,8 +223,7 @@ var _ = Describe("Upgrade", func() {
224223
disconnectedInstallation: true,
225224
modifyHostsFiles: true,
226225
dockerRegistryCAPath: caFile,
227-
dockerRegistryIP: repoNode.PrivateIP,
228-
dockerRegistryPort: dockerRegistryPort,
226+
dockerRegistryServer: fmt.Sprintf("%s:%d", repoNode.PrivateIP, dockerRegistryPort),
229227
dockerRegistryUsername: "kismaticuser",
230228
dockerRegistryPassword: "kismaticpassword",
231229
}
@@ -382,8 +380,7 @@ var _ = Describe("Upgrade", func() {
382380
disconnectedInstallation: true,
383381
modifyHostsFiles: true,
384382
dockerRegistryCAPath: caFile,
385-
dockerRegistryIP: repoNode.PrivateIP,
386-
dockerRegistryPort: dockerRegistryPort,
383+
dockerRegistryServer: fmt.Sprintf("%s:%d", repoNode.PrivateIP, dockerRegistryPort),
387384
dockerRegistryUsername: "kismaticuser",
388385
dockerRegistryPassword: "kismaticpassword",
389386
}
@@ -450,8 +447,7 @@ var _ = Describe("Upgrade", func() {
450447
disconnectedInstallation: true,
451448
modifyHostsFiles: true,
452449
dockerRegistryCAPath: caFile,
453-
dockerRegistryIP: repoNode.PrivateIP,
454-
dockerRegistryPort: dockerRegistryPort,
450+
dockerRegistryServer: fmt.Sprintf("%s:%d", repoNode.PrivateIP, dockerRegistryPort),
455451
dockerRegistryUsername: "kismaticuser",
456452
dockerRegistryPassword: "kismaticpassword",
457453
}

pkg/ansible/clustercatalog.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,7 @@ type ClusterCatalog struct {
2727

2828
ConfigureDockerWithPrivateRegistry bool `yaml:"configure_docker_with_private_registry"`
2929
DockerRegistryCAPath string `yaml:"docker_certificates_ca_path"`
30-
DockerRegistryAddress string `yaml:"docker_registry_address"`
31-
DockerRegistryPort string `yaml:"docker_registry_port"`
30+
DockerRegistryServer string `yaml:"docker_registry_full_url"`
3231
DockerRegistryUsername string `yaml:"docker_registry_username"`
3332
DockerRegistryPassword string `yaml:"docker_registry_password"`
3433

pkg/cli/seed.go

+2-8
Original file line numberDiff line numberDiff line change
@@ -118,21 +118,15 @@ func doSeedRegistry(stdout, stderr io.Writer, options seedRegistryOptions, image
118118
util.PrettyPrintOk(stdout, "Reading installation plan file %q", options.planFile)
119119
// Validate the registry info in the plan file
120120
errs := []error{}
121-
if plan.DockerRegistry.Address == "" {
121+
if plan.DockerRegistry.Server == "" {
122122
errs = append(errs, errors.New("The private registry's address must be set in the plan file."))
123123
}
124-
if plan.DockerRegistry.Port == 0 {
125-
errs = append(errs, errors.New("The private registry's port must be set in the plan file."))
126-
}
127-
if plan.DockerRegistry.Port < 1 || plan.DockerRegistry.Port > 65535 {
128-
errs = append(errs, fmt.Errorf("The private registry port '%d' provided in the plan file is not valid.", plan.DockerRegistry.Port))
129-
}
130124
if len(errs) > 0 {
131125
util.PrettyPrintErr(stdout, "Validating registry configured in plan file")
132126
util.PrintValidationErrors(stdout, errs)
133127
return errors.New("Invalid registry configuration found in plan file")
134128
}
135-
server = fmt.Sprintf("%s:%d", plan.DockerRegistry.Address, plan.DockerRegistry.Port)
129+
server = plan.DockerRegistry.Server
136130
}
137131

138132
im, err := readImageManifest()

pkg/inspector/rule/rule_set.go

-9
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,6 @@ const defaultRuleSet = `---
139139
port: 10250
140140
timeout: 5s
141141
142-
# Port used by Docker registry
143-
- kind: TCPPortAvailable
144-
when: ["master"]
145-
port: 8443
146-
- kind: TCPPortAccessible
147-
when: ["master"]
148-
port: 8443
149-
timeout: 5s
150-
151142
# Port used by Ingress
152143
- kind: TCPPortAvailable
153144
when: ["ingress"]

pkg/install/execute.go

+1-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import (
77
"io/ioutil"
88
"os"
99
"path/filepath"
10-
"strconv"
1110
"time"
1211

1312
"strings"
@@ -685,8 +684,7 @@ func (ae *ansibleExecutor) buildClusterCatalog(p *Plan) (*ansible.ClusterCatalog
685684

686685
if p.PrivateRegistryProvided() {
687686
cc.ConfigureDockerWithPrivateRegistry = true
688-
cc.DockerRegistryAddress = p.DockerRegistry.Address
689-
cc.DockerRegistryPort = strconv.Itoa(p.DockerRegistry.Port)
687+
cc.DockerRegistryServer = p.DockerRegistry.Server
690688
cc.DockerRegistryCAPath = p.DockerRegistry.CAPath
691689
cc.DockerRegistryUsername = p.DockerRegistry.Username
692690
cc.DockerRegistryPassword = p.DockerRegistry.Password

pkg/install/plan.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,10 @@ func readDeprecatedFields(p *Plan) {
9292
Disable: p.AddOns.DashboardDeprecated.Disable,
9393
}
9494
}
95+
96+
if p.DockerRegistry.Server == "" && p.DockerRegistry.Address != "" && p.DockerRegistry.Port != 0 {
97+
p.DockerRegistry.Server = fmt.Sprintf("%s:%d", p.DockerRegistry.Address, p.DockerRegistry.Port)
98+
}
9599
}
96100

97101
func setDefaults(p *Plan) {
@@ -285,9 +289,6 @@ func buildPlanFromTemplateOptions(templateOpts PlanTemplateOptions) Plan {
285289
p.Cluster.Certificates.Expiry = "17520h"
286290
p.Cluster.Certificates.CAExpiry = defaultCAExpiry
287291

288-
// Set DockerRegistry defaults
289-
p.DockerRegistry.Port = 8443
290-
291292
// Add-Ons
292293
// CNI
293294
p.AddOns.CNI = &CNI{}
@@ -424,8 +425,7 @@ var commentMap = map[string][]string{
424425
"docker.storage.direct_lvm.block_device": []string{"Path to the block device that will be used for direct-lvm mode. This", "device will be wiped and used exclusively by docker."},
425426
"docker.storage.direct_lvm.enable_deferred_deletion": []string{"Set to true if you want to enable deferred deletion when using", "direct-lvm mode."},
426427
"docker_registry": []string{"If you want to use an internal registry for the installation or upgrade, you", "must provide its information here. You must seed this registry before the", "installation or upgrade of your cluster. This registry must be accessible from", "all nodes on the cluster."},
427-
"docker_registry.address": []string{"IP or hostname for your registry."},
428-
"docker_registry.port": []string{"Port for your registry."},
428+
"docker_registry.server": []string{"IP or hostname and port for your registry."},
429429
"docker_registry.CA": []string{"Absolute path to the certificate authority that should be trusted when", "connecting to your registry."},
430430
"docker_registry.username": []string{"Leave blank for unauthenticated access."},
431431
"docker_registry.password": []string{"Leave blank for unauthenticated access."},

pkg/install/plan_types.go

+10-3
Original file line numberDiff line numberDiff line change
@@ -238,12 +238,19 @@ type DockerStorageDirectLVM struct {
238238

239239
// DockerRegistry details for docker registry, either confgiured by the cli or customer provided
240240
type DockerRegistry struct {
241+
// The hostname or IP address and port of a private container image registry.
242+
// Do not include http or https.
243+
// When performing a disconnected installation, this registry will be used
244+
// to fetch all the required container images.
245+
Server string
241246
// The hostname or IP address of a private container image registry.
242247
// When performing a disconnected installation, this registry will be used
243248
// to fetch all the required container images.
244-
Address string
249+
// +deprecated
250+
Address string `yaml:"address,omitempty"`
245251
// The port on which the private container image registry is listening on.
246-
Port int
252+
// +deprecated
253+
Port int `yaml:"port,omitempty"`
247254
// The absolute path of the Certificate Authority that should be installed on
248255
// all cluster nodes that have a docker daemon.
249256
// This is required to establish trust between the daemons and the private
@@ -666,7 +673,7 @@ func hasIP(nodes *[]Node, ip string) bool {
666673
// PrivateRegistryProvided returns true when the details about a private
667674
// registry have been provided
668675
func (p Plan) PrivateRegistryProvided() bool {
669-
return p.DockerRegistry.Address != ""
676+
return p.DockerRegistry.Server != ""
670677
}
671678

672679
// NetworkConfigured returns true if pod validation/smoketest should run

pkg/install/test/plan-template-with-storage.golden.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,8 @@ docker:
103103
# all nodes on the cluster.
104104
docker_registry:
105105

106-
# IP or hostname for your registry.
107-
address: ""
108-
109-
# Port for your registry.
110-
port: 8443
106+
# IP or hostname and port for your registry.
107+
server: ""
111108

112109
# Absolute path to the certificate authority that should be trusted when
113110
# connecting to your registry.

pkg/install/test/plan-template.golden.yaml

+2-5
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,8 @@ docker:
103103
# all nodes on the cluster.
104104
docker_registry:
105105

106-
# IP or hostname for your registry.
107-
address: ""
108-
109-
# Port for your registry.
110-
port: 8443
106+
# IP or hostname and port for your registry.
107+
server: ""
111108

112109
# Absolute path to the certificate authority that should be trusted when
113110
# connecting to your registry.

pkg/install/validate.go

-3
Original file line numberDiff line numberDiff line change
@@ -484,9 +484,6 @@ func (dr *DockerRegistry) validate() (bool, []error) {
484484
if dr.Address == "" && (dr.CAPath != "") {
485485
v.addError(fmt.Errorf("Docker Registry address cannot be empty when CA is provided"))
486486
}
487-
if dr.Address != "" && (dr.Port < 1 || dr.Port > 65535) {
488-
v.addError(fmt.Errorf("Docker Registry port %d is invalid. Port must be in the range 1-65535", dr.Port))
489-
}
490487
if _, err := os.Stat(dr.CAPath); dr.CAPath != "" && os.IsNotExist(err) {
491488
v.addError(fmt.Errorf("Docker Registry CA file was not found at %q", dr.CAPath))
492489
}

pkg/install/validate_test.go

+1-2
Original file line numberDiff line numberDiff line change
@@ -849,8 +849,7 @@ func TestValidatePlanDisconnectedInstallationFailsDueToMissingRegistry(t *testin
849849
func TestValidatePlanDisconnectedInstallationSucceeds(t *testing.T) {
850850
plan := validPlan
851851
plan.Cluster.DisconnectedInstallation = true
852-
plan.DockerRegistry.Address = "localhost"
853-
plan.DockerRegistry.Port = 5000
852+
plan.DockerRegistry.Server = "localhost:5000"
854853
if ok, errs := plan.validate(); !ok {
855854
t.Error("expected validation to succeed, but it failed")
856855
t.Logf("errors were: %v\n", errs)

0 commit comments

Comments
 (0)