Aggiornamento del segreto di pull globale nei cluster Satellite
Dopo aver configurato un cluster Satellite, è possibile aggiornare il pull secret globale del cluster per eseguire il pull da un registro di contenitori privato diverso da quay.io o icr.io. Ad esempio, è possibile estrarre
le immagini dal Registro dei titoli di Cloud Pak (cp.icr.io) o dal proprio registro privato.
Esistono due modi per aggiornare il segreto di pull globale nei cluster Satellite.
- Aggiornamento del segreto di pull globale.
- Utilizzare questo approccio se si dispone di uno o più cluster da gestire. Devi ripetere questi passi per ogni cluster in cui vuoi applicare il segreto.
- Aggiornamento del segreto di pull globale utilizzando la configurazione Satellite.
- Utilizza questo approccio se mantieni diversi cluster e gruppi di cluster Satellite. Utilizzando la configurazione Satellite, puoi applicare le modifiche segrete nei tuoi cluster e gruppi di cluster Satellite.
Aggiornamento del segreto di pull globale
Completa la seguente procedura per aggiornare il segreto di pull globale nel tuo cluster Satellite.
- Creare un segreto che abbia le credenziali per il registro che si desidera utilizzare.
Comandooc create secret docker-registry docker-auth-secret \ --docker-server=REGISTRY \ --docker-username=USERNAME \ --docker-password=PASSWORD \ --namespace kube-systemcreate secretdi esempio per l'utilizzo del registro autorizzato Cloud Pak.oc create secret docker-registry docker-auth-secret \ --docker-server=cp.icr.io \ --docker-username=cp \ --docker-password=ENTITLEMENT-KEY \ --namespace kube-system - Crea un DaemonSet per applicare il segreto a tutti i nodi di lavoro.
cat << EOF | oc create -f - apiVersion: apps/v1 kind: DaemonSet metadata: name: update-docker-config namespace: kube-system labels: app: update-docker-config spec: selector: matchLabels: name: update-docker-config template: metadata: labels: name: update-docker-config spec: initContainers: - command: ["/bin/sh", "-c"] args: - > echo "Checking if RHEL or RHCOS host"; [[ -s /docker-config/.docker/config.json ]] && CONFIG_PATH=/docker-config/.docker || CONFIG_PATH=/docker-config/root/.docker; echo "Backing up or restoring config.json"; [[ -s \$CONFIG_PATH/config.json ]] && cp \$CONFIG_PATH/config.json \$CONFIG_PATH/config.json.bak || cp \$CONFIG_PATH/config.json.bak \$CONFIG_PATH/config.json; echo "Merging secret with config.json"; /host/usr/bin/jq -s '.[0] * .[1]' \$CONFIG_PATH/config.json /auth/.dockerconfigjson > \$CONFIG_PATH/config.tmp; mv \$CONFIG_PATH/config.tmp \$CONFIG_PATH/config.json; echo "Sending signal to reload crio config"; pidof crio; kill -1 \$(pidof crio) image: icr.io/ibm/alpine:latest imagePullPolicy: IfNotPresent name: updater resources: {} securityContext: privileged: true volumeMounts: - name: docker-auth-secret mountPath: /auth - name: docker mountPath: /docker-config - name: bin mountPath: /host/usr/bin - name: lib64 mountPath: /lib64 containers: - resources: requests: cpu: 0.01 image: icr.io/ibm/alpine:latest name: sleepforever command: ["/bin/sh", "-c"] args: - > while true; do sleep 100000; done hostPID: true volumes: - name: docker-auth-secret secret: secretName: docker-auth-secret - name: docker hostPath: path: / - name: bin hostPath: path: /usr/bin - name: lib64 hostPath: path: /lib64 hostPathType: Directory EOF - Verifica che i pod siano in esecuzione.
oc get daemonset -n kube-system update-docker-config
Aggiornamento del segreto di pull globale utilizzando la config Satellite
Completa la seguente procedura per utilizzare la configurazione Satellite per applicare il segreto di pull globale ai tuoi cluster e gruppi di cluster Satellite.
-
Crea un segreto in uno dei tuoi cluster Satellite. Notare che questo segreto verrà eliminato in un secondo momento.
oc create secret docker-registry docker-auth-secret \ --docker-server=REGISTRY \ --docker-username=USERNAME \ --docker-password=PASSWORD \ --namespace kube-systemComando
create secretdi esempio per l'utilizzo del registro autorizzato Cloud Pak.oc create secret docker-registry docker-auth-secret \ --docker-server=cp.icr.io \ --docker-username=cp \ --docker-password=ENTITLEMENT-KEY \ --namespace kube-system -
Ottenete i dettagli del vostro segreto. Copia e salva la sezione base64 encoded
dockerconfigjson.oc get secret docker-auth-secret -o yaml -
Eliminare il segreto.
oc delete secret docker-auth-secret -n kube-system -
Creare un file di configurazione denominato
secret.yamlche disponga delle proprie credenziali di registro. Incolla la sezione base64 codificatadockerconfigjsonche hai salvato nel passo precedente.kind: Secret apiVersion: v1 metadata: name: docker-auth-secret namespace: kube-system data: .dockerconfigjson: >- BASE64-ENCODED-SECRET type: kubernetes.io/dockerconfigjson -
Creare una configurazione di Satellite. Nell'opzione
--data-location, specificare la regione Gestito da dell'ubicazione.ibmcloud sat config create --data-location wdc --name my-config -
Aggiungere una versione alla configurazione. Specificare il percorso del file
secret.yamlcreato in precedenza.ibmcloud sat config version create --name 1 --config my-config --file-format yaml --read-config /Users/username/Desktop/secret.yaml -
Creare una sottoscrizione per applicare DaemonSet ad un gruppo di cluster.
ibmcloud sat subscription create --name my-subscription --config my-config --group GROUP -
Salvare il seguente DaemonSet in un file denominato
ds.yaml.apiVersion: apps/v1 kind: DaemonSet metadata: name: update-docker-config namespace: kube-system labels: app: update-docker-config spec: selector: matchLabels: name: update-docker-config template: metadata: labels: name: update-docker-config spec: initContainers: - command: ["/bin/sh", "-c"] args: - > echo "Checking if RHEL or RHCOS host"; [[ -s /docker-config/.docker/config.json ]] && CONFIG_PATH=/docker-config/.docker || CONFIG_PATH=/docker-config/root/.docker; echo "Backing up or restoring config.json"; [[ -s \$CONFIG_PATH/config.json ]] && cp \$CONFIG_PATH/config.json \$CONFIG_PATH/config.json.bak || cp \$CONFIG_PATH/config.json.bak \$CONFIG_PATH/config.json; echo "Merging secret with config.json"; /host/usr/bin/jq -s '.[0] * .[1]' \$CONFIG_PATH/config.json /auth/.dockerconfigjson > \$CONFIG_PATH/config.tmp; mv \$CONFIG_PATH/config.tmp \$CONFIG_PATH/config.json; echo "Sending signal to reload crio config"; pidof crio; kill -1 \$(pidof crio) image: icr.io/ibm/alpine:latest imagePullPolicy: IfNotPresent name: updater resources: {} securityContext: privileged: true volumeMounts: - name: docker-auth-secret mountPath: /auth - name: docker mountPath: /docker-config - name: bin mountPath: /host/usr/bin - name: lib64 mountPath: /lib64 containers: - resources: requests: cpu: 0.01 image: icr.io/ibm/alpine:latest name: sleepforever command: ["/bin/sh", "-c"] args: - > while true; do sleep 100000; done hostPID: true volumes: - name: docker-auth-secret secret: secretName: docker-auth-secret - name: docker hostPath: path: / - name: bin hostPath: path: /usr/bin - name: lib64 hostPath: path: /lib64 hostPathType: Directory -
Creare una configurazione di Satellite. Nell'opzione
--data-location, specificare la regione Gestito da della propria ubicazione, ad esempiowdc.ibmcloud sat config create --data-location wdc --name my-ds -
Aggiungere una versione alla configurazione. Specificare il percorso del file
ds.yamlcreato in precedenza.ibmcloud sat config version create --name 1 --config my-ds --file-format yaml --read-config /Users/username/Desktop/ds.yaml -
Creare una sottoscrizione per applicare DaemonSet ad un gruppo di cluster.
ibmcloud sat subscription create --name my-subscription --config my-ds --group GROUP -
Verificare che il segreto e DaemonSet siano distribuiti tra i cluster.
oc get secret docker-auth-secret -n kube-systemoc get ds update-docker-config -n kube-system
È inoltre possibile visualizzare e gestire le configurazioni e le sottoscrizioni dalla console Satellite.