Merge "Adding secret creation for registry auth"

This commit is contained in:
Jenkins 2017-03-02 09:44:46 +00:00 committed by Gerrit Code Review
commit bb7ce72c20
2 changed files with 18 additions and 2 deletions

View File

@ -596,6 +596,19 @@ def version_diff(from_image, to_image):
return from_tag, to_tag
def _create_registry_secret():
dockercfg = {
CONF.registry.address: {
"username": CONF.registry.username,
"password": CONF.registry.password
}
}
data = {".dockercfg": json.dumps(dockercfg, sort_keys=True)}
secret = templates.serialize_secret(
"registry-key", "kubernetes.io/dockercfg", data)
kubernetes.process_object(secret)
def deploy_components(components_map, components):
topology = _make_topology(CONF.nodes, CONF.roles, CONF.replicas)
@ -613,6 +626,7 @@ def deploy_components(components_map, components):
os.makedirs(os.path.join(CONF.action.export_dir, 'configmaps'))
_create_namespace(CONF.configs)
_create_registry_secret()
_create_globals_configmap(CONF.configs)
_create_nodes_configmap(CONF.nodes)
start_script_cm = create_start_script_configmap()

View File

@ -216,7 +216,8 @@ def serialize_job_pod_spec(service, job, cont_spec, affinity):
"spec": {
"containers": [cont_spec],
"volumes": serialize_volumes(service, job),
"restartPolicy": "OnFailure"
"restartPolicy": "OnFailure",
"imagePullSecrets": [{"name": "registry-key"}]
}
}
@ -231,7 +232,8 @@ def serialize_daemon_pod_spec(service):
"volumes": serialize_volumes(service),
"restartPolicy": "Always",
"hostNetwork": service.get("hostNetwork", False),
"hostPID": service.get("hostPID", False)
"hostPID": service.get("hostPID", False),
"imagePullSecrets": [{"name": "registry-key"}]
}
return cont_spec