I repository Yum in Artifact Registry ti consentono di gestire centralmente i tuoi pacchetti RPM e di mantenere dipendenze software coerenti nei tuoi workload Linux. Puoi aggiungere, visualizzare ed eliminare i pacchetti e installarli utilizzando i gestori di pacchetti Yum o DNF.
Prima di iniziare
- Se il repository Yum di destinazione non esiste, crea un nuovo repository.
- Configura le VM per accedere al repository.
- (Facoltativo) Configura i valori predefiniti per i comandi gcloud.
- Assicurati che i nomi dei pacchetti nei metadati soddisfino le linee guida per la denominazione dei pacchetti Fedora e le linee guida per il controllo delle versioni dei pacchetti Fedora.
Aggiunta di pacchetti
Modalità repository: standard
Per aggiungere pacchetti, devi disporre delle autorizzazioni di lettura e scrittura per il repository.
Puoi caricare un pacchetto in un repository utilizzando Google Cloud CLI o importare un pacchetto archiviato in Cloud Storage.
Se crei pacchetti utilizzando Cloud Build, la build può archiviarli in Cloud Storage per consentirti di importarli.Le operazioni di importazione o caricamento molto lunghe potrebbero superare il periodo di scadenza del token utilizzato da gcloud CLI per chiamare l'API. Se hai un numero molto elevato di pacchetti da aggiungere, valuta la possibilità di aggiungerli in batch più piccoli in modo che ogni operazione di caricamento o importazione possa essere completata in un periodo di tempo più breve. Per saperne di più, consulta la documentazione sulla risoluzione dei problemi relativi ai pacchetti del sistema operativo.
Caricamento diretto
Utilizza il comando gcloud artifacts yum upload per caricare un pacchetto in un repository Yum:
gcloud artifacts yum upload REPOSITORY \
--location=LOCATION \
--source=PACKAGES
Sostituisci i seguenti valori:
REPOSITORYè il nome del repository Artifact Registry.-
LOCATIONè la località regionale o multiregionale del repository. PACKAGESè il percorso del pacchetto.
Ad esempio, per caricare il pacchetto my-package.rpm nel repository Yum my-repo nella località us-west1, esegui:
gcloud artifacts yum upload my-repo \
--location=us-west1 \
--source=my-package.rpm
Cloud Storage
- Carica i pacchetti su Cloud Storage in uno dei seguenti modi:
- Carica i pacchetti direttamente in un bucket Cloud Storage
- Crea pacchetti con Cloud Build e archiviali in un bucket
- Esegui questo comando:
gcloud artifacts yum import REPOSITORY \ --location=LOCATION \ --gcs-source=PACKAGES
Sostituisci i seguenti valori:
REPOSITORYè il nome del repository Artifact Registry.-
LOCATIONè la località regionale o multiregionale del repository. PACKAGESè un elenco separato da virgole di pacchetti in Cloud Storage. Per caricare tutti i pacchetti da una directory, utilizza un carattere jolly per la directory (*) o un carattere jolly per la directory ricorsiva (**) per caricare tutti i pacchetti in tutte le sottodirectory.
Ad esempio, il seguente comando carica il pacchetto
package.rpme tutti i pacchetti nella directorydirectorydal bucketmy-bucketnel repository Yummy-reponella localitàus-west1:gcloud artifacts yum import my-repo \ --location=us-west1 \ --gcs-source=gs://my-bucket/path/to/package.rpm,gs://my-bucket/directory*
Al termine dell'operazione di caricamento o importazione, puoi utilizzare la consoleGoogle Cloud o gcloud CLI per visualizzare i pacchetti nel repository e verificare che siano stati caricati correttamente.
Se hai un repository di grandi dimensioni con molti pacchetti, la rigenerazione dell'indice dei pacchetti potrebbe richiedere diversi minuti per rendere visibili i nuovi pacchetti al client Yum.
Visualizzazione dei pacchetti
Modalità repository: standard, remoto (anteprima)
Per visualizzare i pacchetti, devi disporre delle autorizzazioni nel ruolo Lettore Artifact Registry. Artifact Registry non elenca i file all'interno dei pacchetti.
To view packages and package versions using the Google Cloud console
or gcloud:
Console
Open the Repositories page in the Google Cloud console.
In the repository list, click the appropriate repository.
The Packages page lists the packages in the repository.
Click a package to view versions of the package.
gcloud
To list packages in a repository, run the following command:
gcloud artifacts packages list [--repository=REPOSITORY] [--location=LOCATION]
Replace the following:
REPOSITORYis the name of the repository. If you configured a default repository, you can omit this flag to use the default.-
LOCATIONis the regional or multi-regional location of the repository. If you configured a default location, then you can omit this flag to use the default.
To view versions of a package, run the following command:
gcloud artifacts versions list --package=PACKAGE \
[--repository=REPOSITORY] [--location=LOCATION]
Replace the following:
PACKAGEis the ID of the package or fully qualified identifier for the package.REPOSITORYis the name of the repository. If you configured a default repository, then you can omit this flag to use the default.-
LOCATIONis the regional or multi-regional location of the repository. Use this flag to view repositories in a specific location. If you configured a default location, then you can omit this flag to use the default.
Installazione dei pacchetti
Modalità repository: standard, remoto (anteprima)
Prima di installare i pacchetti, verifica di aver configurato la VM per installare i pacchetti dal repository Artifact Registry.
Per installare un pacchetto, esegui questo comando:
sudo yum --enablerepo=REPOSITORY install PACKAGE
Sostituisci i seguenti valori:
PACKAGEè il nome del pacchettoREPOSITORYè il nome del repository configurato nel file.repo.
Ad esempio, per installare il pacchetto my-package dal repository
my-repo, esegui il comando:
sudo yum --enablerepo=my-repo install my-package
Eliminazione dei pacchetti
Modalità repository: standard
Before you delete a package or package version, verify that any you have communicated or addressed any important dependencies on it.
To delete a package:
Console
Open the Repositories page in the Google Cloud console.
In the repository list, click the appropriate repository.
The Packages page lists the packages in the repository.
Select the package that you want to delete.
Click DELETE.
In the confirmation dialog box, click DELETE.
gcloud
Run the following command:
gcloud artifacts packages delete PACKAGE \
[--repository=REPOSITORY] [--location=LOCATION] [--async]
Replace the following:
PACKAGEis the name of the package in the repository.REPOSITORYis the name of the repository. If you configured a default repository, then you can omit this flag to use the default.-
LOCATIONis the regional or multi-regional location of the repository. Use this flag to view repositories in a specific location. If you configured a default location, then you can omit this flag to use the default.
The --async flag causes the command to return immediately,
without waiting for the operation in progress to complete.
To delete versions of a package:
Console
Open the Repositories page in the Google Cloud console.
In the repository list, click the appropriate repository.
The Packages page lists the packages in the repository.
Click a package to view versions of that package.
Select versions that you want to delete.
Click DELETE.
In the confirmation dialog box, click DELETE.
gcloud
Run the following command:
gcloud artifacts versions delete VERSION \
--package=PACKAGE \
[--repository=REPOSITORY] [--location=LOCATION] \
[--async]
Replace the following:
VERSIONis the name of the version to delete.PACKAGEis the name of the package in the repository.REPOSITORYis the name of the repository. If you configured a default repository, then you can omit this flag to use the default.-
LOCATIONis the regional or multi-regional location of the repository. Use this flag to view repositories in a specific location. If you configured a default location, then you can omit this flag to use the default.
The --async flag causes the command to return immediately,
without waiting for the operation in progress to complete.
Per i repository di grandi dimensioni, la rigenerazione dell'indice dei pacchetti Yum per riflettere le eliminazioni può richiedere alcuni minuti.