Add custom docker registry to DockerStandaloneHost

Allow access to private docker registry using docker argument
'--insecure-registry'.
Add new field for docker private registry host ip or domain name.

Partially implements: blueprint k8s-docker-enterprise-hub-support

Change-Id: I0e7b0ceebe9deda090fff56ec87f3c615050cc2a
This commit is contained in:
Tetiana Lashchova 2015-10-20 17:28:01 +03:00
parent 0549313491
commit f75e1e9700
6 changed files with 90 additions and 28 deletions

View File

@ -31,6 +31,9 @@ Properties:
dockerRegistry:
Contract: $.string()
dockerMirror:
Contract: $.string()
applicationEndpoints:
Contract:
- port: $.int().notNull().check($ > 0)
@ -65,11 +68,13 @@ Methods:
- $resources: new(sys:Resources)
- $template: $resources.yaml('StartDocker.template')
- $.instance.agent.call($template, $resources)
- If: $.dockerRegistry != null and $.dockerRegistry != ''
- If: $.dockerMirror != null and $.dockerMirror != ''
or $.dockerRegistry != null and $.dockerRegistry != ''
Then:
- $._environment.reporter.report($this, 'Configuring Docker registry')
- $template: $resources.yaml('SetupDockerRegistry.template').bind(dict(
dockerRegistry => $.dockerRegistry
- $._environment.reporter.report($this, 'Configuring Docker options')
- $template: $resources.yaml('SetupDockerOptions.template').bind(dict(
dockerRegistry => $.dockerRegistry,
dockerMirror => $.dockerMirror
))
- $.instance.agent.call($template, $resources)
- $._environment.reporter.report($this, 'Docker Server is up and running')

View File

@ -0,0 +1,53 @@
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
FormatVersion: 2.0.0
Version: 1.0.0
Name: Setup Docker options
Parameters:
dockerRegistry: $dockerRegistry
dockerMirror: $dockerMirror
Body: |
if args.dockerRegistry:
setupRegistry(args.dockerRegistry)
if args.dockerMirror:
setupMirror(args.dockerMirror)
restartDocker()
Scripts:
setupMirror:
Type: Application
Version: 1.0.0
EntryPoint: setupDockerMirror.sh
Files: []
Options:
captureStdout: true
captureStderr: true
setupRegistry:
Type: Application
Version: 1.0.0
EntryPoint: setupDockerRegistry.sh
Files: []
Options:
captureStdout: true
captureStderr: true
restartDocker:
Type: Application
Version: 1.0.0
EntryPoint: restartDocker.sh
Options:
captureStdout: false
captureStderr: false

View File

@ -1,3 +1,4 @@
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
@ -10,22 +11,4 @@
# License for the specific language governing permissions and limitations
# under the License.
FormatVersion: 2.0.0
Version: 1.0.0
Name: Setup Docker registry
Parameters:
dockerRegistry: $dockerRegistry
Body: |
setupRegistry(args.dockerRegistry)
Scripts:
setupRegistry:
Type: Application
Version: 1.0.0
EntryPoint: setupDockerRegistry.sh
Files: []
Options:
captureStdout: true
captureStderr: true
service docker restart

View File

@ -0,0 +1,16 @@
#!/bin/bash
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.
source /etc/default/docker
DOCKER_OPTS+=" --registry-mirror=$1"
echo DOCKER_OPTS=\"$DOCKER_OPTS\" > /etc/default/docker

View File

@ -12,7 +12,5 @@
# under the License.
source /etc/default/docker
DOCKER_OPTS+=" --registry-mirror=$1"
echo DOCKER_OPTS=\"$DOCKER_OPTS\" > /etc/default/docker
service docker restart
DOCKER_OPTS+=" --insecure-registry $1"
echo DOCKER_OPTS=\"$DOCKER_OPTS\" > /etc/default/docker

View File

@ -17,6 +17,7 @@ Application:
type: io.murano.apps.docker.DockerStandaloneHost
name: $.appConfiguration.name
dockerRegistry: $.appConfiguration.dockerRegistry
dockerMirror: $.appConfiguration.dockerMirror
instance:
?:
type: io.murano.resources.LinuxMuranoInstance
@ -53,7 +54,13 @@ Forms:
type: string
label: Custom Docker registry URL
description: >-
URL of docker repository mirror to use. Leave empty for Docker default
Host IP or domain name of custom Docker registry to use. Leave empty for Docker default
required: false
- name: dockerMirror
type: string
label: Docker registry mirror URL
description: >-
URL of Docker registry mirror to use. Leave empty to not use one
required: false
- instanceConfiguration: