mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-08-03 09:22:44 +00:00
Add docker-logins config to kubernetes-worker
This commit is contained in:
parent
d0301aa6e8
commit
ca9076cf0f
@ -49,3 +49,12 @@ options:
|
|||||||
runtime-config=batch/v2alpha1=true profiling=true
|
runtime-config=batch/v2alpha1=true profiling=true
|
||||||
will result in kube-apiserver being run with the following options:
|
will result in kube-apiserver being run with the following options:
|
||||||
--runtime-config=batch/v2alpha1=true --profiling=true
|
--runtime-config=batch/v2alpha1=true --profiling=true
|
||||||
|
docker-logins:
|
||||||
|
type: string
|
||||||
|
default: "[]"
|
||||||
|
description: |
|
||||||
|
Docker login credentials. Setting this config allows Kubelet to pull images from
|
||||||
|
registries where auth is required.
|
||||||
|
|
||||||
|
The value for this config must be a JSON array of credential objects, like this:
|
||||||
|
[{"server": "my.registry", "username": "myUser", "password": "myPass"}]
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
import json
|
||||||
import os
|
import os
|
||||||
import random
|
import random
|
||||||
import shutil
|
import shutil
|
||||||
@ -435,6 +436,32 @@ def extra_args_changed():
|
|||||||
set_state('kubernetes-worker.restart-needed')
|
set_state('kubernetes-worker.restart-needed')
|
||||||
|
|
||||||
|
|
||||||
|
@when('config.changed.docker-logins')
|
||||||
|
def docker_logins_changed():
|
||||||
|
config = hookenv.config()
|
||||||
|
previous_logins = config.previous('docker-logins')
|
||||||
|
logins = config['docker-logins']
|
||||||
|
logins = json.loads(logins)
|
||||||
|
|
||||||
|
if previous_logins:
|
||||||
|
previous_logins = json.loads(previous_logins)
|
||||||
|
next_servers = {login['server'] for login in logins}
|
||||||
|
previous_servers = {login['server'] for login in previous_logins}
|
||||||
|
servers_to_logout = previous_servers - next_servers
|
||||||
|
for server in servers_to_logout:
|
||||||
|
cmd = ['docker', 'logout', server]
|
||||||
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
|
for login in logins:
|
||||||
|
server = login['server']
|
||||||
|
username = login['username']
|
||||||
|
password = login['password']
|
||||||
|
cmd = ['docker', 'login', server, '-u', username, '-p', password]
|
||||||
|
subprocess.check_call(cmd)
|
||||||
|
|
||||||
|
set_state('kubernetes-worker.restart-needed')
|
||||||
|
|
||||||
|
|
||||||
def arch():
|
def arch():
|
||||||
'''Return the package architecture as a string. Raise an exception if the
|
'''Return the package architecture as a string. Raise an exception if the
|
||||||
architecture is not supported by kubernetes.'''
|
architecture is not supported by kubernetes.'''
|
||||||
|
Loading…
Reference in New Issue
Block a user