Skip to content

Commit

Permalink
415 acr oras
Browse files Browse the repository at this point in the history
  • Loading branch information
Houssem Dellai committed Nov 18, 2024
1 parent 2455992 commit 9a46f45
Show file tree
Hide file tree
Showing 8 changed files with 106 additions and 55 deletions.
62 changes: 18 additions & 44 deletions 415_acr_oci_oras_app_artifacts/commands.ps1
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
# src: https://learn.microsoft.com/en-us/azure/container-registry/container-registry-manage-artifact
# install oras cli

winget install oras --version 1.2.0
winget install oras

$RG="rg-acr-oci"
$RG="rg-acr-oci-415"
$ACR_NAME="acrociregistry13"
$REGISTRY="$ACR_NAME.azurecr.io"
$REPO="net-monitor"
$TAG="v1"
$IMAGE="$REGISTRY/${REPO}:$TAG"

az login
# az login # login to Azure if needed
az group create -n $RG -l swedencentral
az acr create -n $ACR_NAME -g $RG --sku Standard
az acr login -n $REGISTRY --expose-token
Expand All @@ -19,49 +18,28 @@ $TOKEN=$(az acr login -n $REGISTRY --expose-token --output tsv --query accessTok
# Sign in with ORAS

oras login $REGISTRY --username "00000000-0000-0000-0000-000000000000" --password $TOKEN
# Login Succeeded
# oras login $REGISTRY --username $USER_NAME --password $PASSWORD

# push a nuget package

oras push $REGISTRY/nuget/newtonsoft:13.0.3 --artifact-type package/nuget ./newtonsoft.json.13.0.3.nupkg

# check the resource in ACR

oras manifest fetch --pretty $REGISTRY/nuget/newtonsoft:13.0.3

# pull the nuget package

mkdir ./download

oras pull -o ./download $REGISTRY/nuget/newtonsoft:13.0.3

# Push and Pull OCI Artifacts with ORAS

oras push $REGISTRY/samples/artifact:readme --artifact-type readme/example ./readme.md:application/markdown
# ✓ Uploaded readme.md 589/589 B 100.00% 635ms
# └─ sha256:f132432a5cb35e8e34c9669cc4c72390ca93cfc24802882941cc82b5d05133bf
# ✓ Uploaded application/vnd.oci.empty.v1+json 2/2 B 100.00% 490ms
# └─ sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
# ✓ Uploaded application/vnd.oci.image.manifest.v1+json 550/550 B 100.00% 287ms
# └─ sha256:370e076ad19b329536da11f27a7db4a34b7f367452f0b615e905525b122cc28b
# Pushed [registry] acrociregistry13.azurecr.io/samples/artifact:readme
# ArtifactType: readme/example
# Digest: sha256:370e076ad19b329536da11f27a7db4a34b7f367452f0b615e905525b122cc28b

# To view the manifest created as a result of oras push, use oras manifest fetch:

oras manifest fetch --pretty $REGISTRY/samples/artifact:readme
# {
# "schemaVersion": 2,
# "mediaType": "application/vnd.oci.image.manifest.v1+json",
# "artifactType": "readme/example",
# "config": {
# "mediaType": "application/vnd.oci.empty.v1+json",
# "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
# "size": 2,
# "data": "e30="
# },
# "layers": [
# {
# "mediaType": "application/markdown",
# "digest": "sha256:f132432a5cb35e8e34c9669cc4c72390ca93cfc24802882941cc82b5d05133bf",
# "size": 589,
# "annotations": {
# "org.opencontainers.image.title": "readme.md"
# }
# }
# ],
# "annotations": {
# "org.opencontainers.image.created": "2024-10-24T10:18:02Z"
# }
# }

# Pull an artifact

Expand All @@ -72,7 +50,3 @@ oras pull -o ./download $REGISTRY/samples/artifact:readme
# Remove the artifact (optional)

oras manifest delete $REGISTRY/samples/artifact:readme

# push a nuget package

oras push $REGISTRY/nuget/newtonsoft:13.0.3 --artifact-type package/nuget ./newtonsoft.json.13.0.3.nupkg
8 changes: 0 additions & 8 deletions 415_acr_oci_oras_app_artifacts/download/readme.md

This file was deleted.

Binary file modified 415_acr_oci_oras_app_artifacts/images/architecture.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed 415_acr_oci_oras_app_artifacts/images/resources.png
Binary file not shown.
85 changes: 85 additions & 0 deletions 415_acr_oci_oras_app_artifacts/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,88 @@ This is how you can use ACR to deploy app packages like `nuget`, `npm`, `maven`,

Azure container registry (ACR) helps you manage both the Open container initiative (OCI) artifacts and supply chain artifacts. This article guides you how to use ACR for managing OCI artifacts and supply chain artifacts effectively. Learn to store, manage, and retrieve both OCI artifacts and a graph of supply chain artifacts, including signatures, software bill of materials (SBOM), security scan results, and other types.

![](images/architecture.png)

Documentation: https://learn.microsoft.com/en-us/azure/container-registry/container-registry-manage-artifact
Oras project: https://oras.land/

## Lab

```sh
winget install oras --version 1.2.0

$RG="rg-acr-oci"
$ACR_NAME="acrociregistry13"
$REGISTRY="$ACR_NAME.azurecr.io"
$REPO="net-monitor"
$TAG="v1"
$IMAGE="$REGISTRY/${REPO}:$TAG"

az login
az group create -n $RG -l swedencentral
az acr create -n $ACR_NAME -g $RG --sku Standard
az acr login -n $REGISTRY --expose-token

$TOKEN=$(az acr login -n $REGISTRY --expose-token --output tsv --query accessToken)

# Sign in with ORAS

oras login $REGISTRY --username "00000000-0000-0000-0000-000000000000" --password $TOKEN
# Login Succeeded
# oras login $REGISTRY --username $USER_NAME --password $PASSWORD

# Push and Pull OCI Artifacts with ORAS

oras push $REGISTRY/samples/artifact:readme --artifact-type readme/example ./readme.md:application/markdown
# ✓ Uploaded readme.md 589/589 B 100.00% 635ms
# └─ sha256:f132432a5cb35e8e34c9669cc4c72390ca93cfc24802882941cc82b5d05133bf
# ✓ Uploaded application/vnd.oci.empty.v1+json 2/2 B 100.00% 490ms
# └─ sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a
# ✓ Uploaded application/vnd.oci.image.manifest.v1+json 550/550 B 100.00% 287ms
# └─ sha256:370e076ad19b329536da11f27a7db4a34b7f367452f0b615e905525b122cc28b
# Pushed [registry] acrociregistry13.azurecr.io/samples/artifact:readme
# ArtifactType: readme/example
# Digest: sha256:370e076ad19b329536da11f27a7db4a34b7f367452f0b615e905525b122cc28b

# To view the manifest created as a result of oras push, use oras manifest fetch:

oras manifest fetch --pretty $REGISTRY/samples/artifact:readme
# {
# "schemaVersion": 2,
# "mediaType": "application/vnd.oci.image.manifest.v1+json",
# "artifactType": "readme/example",
# "config": {
# "mediaType": "application/vnd.oci.empty.v1+json",
# "digest": "sha256:44136fa355b3678a1146ad16f7e8649e94fb4fc21fe77e8310c060f61caaff8a",
# "size": 2,
# "data": "e30="
# },
# "layers": [
# {
# "mediaType": "application/markdown",
# "digest": "sha256:f132432a5cb35e8e34c9669cc4c72390ca93cfc24802882941cc82b5d05133bf",
# "size": 589,
# "annotations": {
# "org.opencontainers.image.title": "readme.md"
# }
# }
# ],
# "annotations": {
# "org.opencontainers.image.created": "2024-10-24T10:18:02Z"
# }
# }

# Pull an artifact

mkdir ./download

oras pull -o ./download $REGISTRY/samples/artifact:readme

# Remove the artifact (optional)

oras manifest delete $REGISTRY/samples/artifact:readme

# push a nuget package

oras push $REGISTRY/nuget/newtonsoft:13.0.3 --artifact-type package/nuget ./newtonsoft.json.13.0.3.nupkg
```
2 changes: 1 addition & 1 deletion 68_kube_egress_gateway/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ az role assignment create --role "Network Contributor" --assignee $AKS_PRINCIPAL
Deploy a sample application to the AKS cluster to use static egress gateway through annotation `kubernetes.azure.com/static-gateway-configuration: my-static-egress-gateway`. And verify that the egress traffic is routed through the static egress gateway.
```sh
kubectl apply -f deployment.yaml
kubectl apply -f nginx-deployment.yaml
kubectl get pods
kubectl exec <pod name> -it -- curl ifconfig.me
```
4 changes: 2 additions & 2 deletions 68_kube_egress_gateway/commands.ps1
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
$AKS_NAME = "aks-cluster"
$AKS_RG = "rg-aks-cluster-egress-gw"
$AKS_RG = "rg-aks-cluster-egress-gateway"
$NODEPOOL_NAME = "npegress"
$GW_PREFIX_SIZE = 30

Expand Down Expand Up @@ -50,7 +50,7 @@ kubectl apply -f static_gateway_config.yaml

kubectl get staticgatewayconfigurations my-static-egress-gateway -n default -o yaml

kubectl apply -f deployment.yaml
kubectl apply -f nginx-deployment.yaml

kubectl get pods

Expand Down
Binary file modified 68_kube_egress_gateway/static_gateway_config.yaml
Binary file not shown.

0 comments on commit 9a46f45

Please sign in to comment.