Categories
DevOps quick q&a

Azure-cli in Dockerfile in Alpine

Today we’ll see how to install Azure-cli in Dockerfile when the base image is Alpine. If you later find this article useful take a look at the disclaimer for information on how to thank me.

As you know azure cli allows you to control azure cloud aspects from command line. This may be useful for provisioning azure resources in ci/cd pipelines or automations, for instance. If the pipelines run inside Jenkins agents (e.g. Docker in Docker Jenkins agent, Podman Jenkins agent) which are containerized, you may need to package azure-cli inside them. Let’s see how to install azure-cli in Dockerfile.

Azure-cli installation in Dockerfile

You probably found it challenging to install Azure-cli as part of Dockerfile where the base image is Alpine.

Use below command sequence to achieve that:

RUN apk add --no-cache --update python3 py3-pip 
RUN apk add --no-cache --update --virtual=build gcc musl-dev python3-dev libffi-dev openssl-dev cargo make && pip3 install --no-cache-dir --prefer-binary azure-cli && apk del build

RUN apk add --no-cache --update python3 py3-pip installed python and pip. They are needed because azure-cli is basically Python package.

Second RUN installs os packages required for successful azure-cli installation. Then, pip installs azure-cli.

See also relevant discussion on GitHub about installation of azure-cli in alpine.

Why apk add –virtual?

Note that these os packages are installed in a virtual package which is removed after azure-cli installation using apk del virtual. This trick reduces the final built image size.

Note also that Azure CLI is a Python package. That’s why it requires Python and Pip to run. Hence these packages are not removed.

See this great answer on stack overflow about apk add --virtual. Note that apk add --no-cache reduces image size as well.

Summary

That’s it about Azure-cli installation in Dockerfile when Alpine is a base image.

Find out recommended Azure books on Amazon.

Find out recommended Azure courses on Pluralsight:

Sign up using this link to get exclusive discounts like 50% off your first month or 15% off an annual subscription)

If you found this article useful, take a look at the disclaimer for information on how to thank me.

Categories
DevOps

Kubernetes StatefulSets Demo

Today, I’ll demo Kubernetes StatefulSets. We’ll see what StatefulSets are, why to use them and how to create them.

Categories
DevOps

Kubernetes CSI Volumes Demo

Today, I’ll demo CSI volumes in Kubernetes world. We’ll see what CSI volumes are, why to use them and what advantage CSI volumes give over regular Kubernetes volumes. If you later find this article useful read the disclaimer on ways to thank me.

Categories
Automation CI/CD DevOps

Backup Jenkins using File System Snapshots

Jenkins docs suggest several ways to backup Jenkins home data. One of the easiest and mysterious ones is using file system snapshots. Luckily there’s a great tool – Kopia which I’ll demo today. We’ll backup Jenkins controller’s data to S3 bucket on the cloud.

If you later find this article useful take a look at the disclaimer for information on how to thank me.

Categories
Best Practices DevOps Orchestration

Dynamic Provisioning of Kubernetes Storage

If you are a professional Kubernetes storage administrator you probably performed dynamic provisioning of Kubernetes storage and avoided creating the volumes manually. We’ll see the motivation for dynamic storage provisioning and how using storage classes serves this purpose.

If you later find this article useful take a look at the disclaimer for information on how to thank me.

Categories
Best Practices

Git Tricks: git commit –amend + git force –push

Time has come to share useful git tricks and commands like git commit --amend + git force --push. We’ll show how using them helps us to keep git history stable.

If you later find this article useful take a look at the disclaimer for information on how to thank me.

Categories
Best Practices networking Orchestration

Kubernetes Ingress Demo

You have probably heard of Kubernetes ingress. What purpose does it serve? How to use it? Keep reading to find out.

Categories
DevOps networking

Kubernetes Networking Explained

Kubernetes networking might seem like a service we get for free from Kubernetes. Yet, it’s important to understand the principles and ideas behind it. Keep reading to find them out.

Categories
CI/CD DevOps

Helm Charts CI/CD: Chart Dependencies

How to handle helm chart dependencies as part of CI/CD pipelines? Keep reading to find out. We’ll explore helm charts SDLC in the context of charts dependencies and base CI/CD on it.

If you later find this article useful take a look at the disclaimer for information on how to thank me.

Categories
Best Practices CI/CD DevOps

How to test helm charts?

As a developer of helm charts’ CI/CD pipelines you probably wondered how to test Helm Charts. This may seem challenging because on the one hand, it seems like there’s nothing to test. On the other hand, you probably encountered numerous cases when the deployment of helm chart failed because of some missing bracket. Keep reading to find out how to test helm charts. If you later find this article useful take a look at the disclaimer for information on how to thank me.