Skip to content

Instantly share code, notes, and snippets.

@sajayantony
sajayantony / build-mult-arch-artifact.sh
Last active June 26, 2024 00:38
Script to help create a simple mult-arch artifact
#!/bin/bash
echo 'linux/amd64' > README-linux-amd64.md
echo 'linux/arm64' > README-linux-arm64.md
# Push the artifact for amd64 and get the digest
DIGEST_LINUX_AMD64=$(oras push --oci-layout layout-dir README-linux-amd64.md --format go-template='{{.digest}}')
# Push the artifact for arm64 and get the digest
DIGEST_LINUX_ARM64=$(oras push --oci-layout layout-dir README-linux-arm64.md --format go-template='{{.digest}}')
@sajayantony
sajayantony / acr-vm-scheduled-startup.sh
Created May 28, 2024 22:01
Schedule VM Start using ACR Tasks
#!/bin/bash
# Variables
acrName=
resourceGroup=
vmName=
# Create ACR task with encoded YAML
az acr task create \
--name startvm \
@sajayantony
sajayantony / ssh-tutorial.md
Created October 18, 2023 18:32 — forked from slowkow/ssh-tutorial.md
ssh to a server without typing your password

How to ssh to a remote server without typing your password

Save yourself a few keystrokes. Follow the steps below:

  1. Run this Bash script on your laptop:

    #!/usr/bin/env bash
    

The hostname of your remote server.

Configure ACR cache with Docker Hub token

Create a DockerHub Reaonly Access Token.

Create readonly token in the security tab - https://hub.docker.com/settings/security

Create a Keyvault to hold this access token

This is optional and you can use an existing keyvault

#gh api repos/opencontainers/image-spec/contributors > /tmp/contributors.json
# cat /tmp/contributors.json | jq -r '.[] | @text "| \(.login) | ![avatar](\(.avatar_url)) | "'
get_contributors()
{
REPO=$1
FILE_NAME=/tmp/contributors-$REPO.json
gh api repos/opencontainers/$REPO/contributors > $FILE_NAME
cat $FILE_NAME | jq -r '.[] | @text "| \(.login) | ![avatar](\(.avatar_url)) | "'
}
@sajayantony
sajayantony / Keybase.md
Created January 19, 2022 22:56
Keybase.md

Keybase proof

I hereby claim:

  • I am sajayantony on github.
  • I am sajaya (https://keybase.io/sajaya) on keybase.
  • I have a public key ASB_QMcvNErLxHk0QOaoWgQB18x1QKMqcY65857ALb3rRwo

To claim this, I am signing this object:

@sajayantony
sajayantony / delete-ec2-volumes.sh
Created November 9, 2021 19:49
Deleting EC2 volumes
#!/bin/bash
for REGION in $(aws ec2 describe-regions --output text --query 'Regions[].[RegionName]'| cat) ; do
echo $REGION
id=$(aws ec2 describe-volumes \
--filter "Name=status,Values=available" \
--query 'Volumes[*].[VolumeId]' \
--output text --region $REGION | cat) ;
echo $id
@sajayantony
sajayantony / diag.svg
Last active November 2, 2021 22:31
oras-types-uml
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Downloading a tarball from ACR with anonymous access

  • Create a registry with anonymous access enabled.
export REGISTRY_NAME=sphere
export REGISTRY=${REGISTRY_NAME}".azurecr.io"
az acr create --name $REGISTRY_NAME  --sku Premium --resource-group test --location wcus
az acr update -n $REGISTRY_NAME --anonymous-pull-enabled true
@sajayantony
sajayantony / get-docker-config.sh
Last active January 6, 2021 19:22
Obtain the Config blob from the registry from Manifest digest
#!/bin/sh
set -e
REGISTRY="sajay.azurecr.io"
REPOSITORY="hello-world"
AAD_ACCESS_TOKEN=$(az account get-access-token --query accessToken -o tsv)
ACR_REFRESH_TOKEN=$(curl -s -X POST -H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=access_token&service=$REGISTRY&access_token=$AAD_ACCESS_TOKEN" \
https://$REGISTRY/oauth2/exchange \