Install Azure CLI on EC2 CentOS7 and Connect to Azure AKS

I have been told to restart the internal monitoring system today and after some consideration, I have decided to deploy the monitoring system on Azure AKS. As titled, I will install Azure CLI on a CentOS7 hosted on EC2 and use it to connect to the already provisioned Azure AKS.

This will be a short post, let’s get started!

Steps:

  1. Install azure-cli
  2. Install kubectl
  3. Login to Azure, get AKS credential file and connect

Setup Azure Cli repository and install Cli. Refer here for more details.

sudo rpm - import https://packages.microsoft.com/keys/microsoft.ascsudo sh -c 'echo -e "[azure-cli]
name=Azure CLI
baseurl=https://packages.microsoft.com/yumrepos/azure-cli
enabled=1
gpgcheck=1
gpgkey=https://packages.microsoft.com/keys/microsoft.asc" > /etc/yum.repos.d/azure-cli.repo'
yum install azure-cli

Next, install kubectl. Refer here for more details.

cat <<EOF > /etc/yum.repos.d/kubernetes.repo
[kubernetes]
name=Kubernetes
baseurl=https://packages.cloud.google.com/yum/repos/kubernetes-el7-x86_64
enabled=1
gpgcheck=1
repo_gpgcheck=1
gpgkey=https://packages.cloud.google.com/yum/doc/yum-key.gpg https://packages.cloud.google.com/yum/doc/rpm-package-key.gpg
EOF
yum install -y kubectl

Once done, verify the result.

Next, login to Azure, get credential file from Azure AKS and verify that you can access AKS from EC2.

az loginaz account set --subscription YOUR_SUBSCRIPTIONaz aks get-credentials --resource-group AKS_RG_NAME --name AKS_CLUSTER_NAMEkubectl cluster-info

With some simple kubectl commands to check out the cluster.

That’s it! Now we can access Azure AKS from client side!

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Yst@IT

Yst@IT

AWS Certified SA, SysOps & Developer Associate, Alibaba Cloud certified SA. Focusing on Azure, Prometheus w/ Grafana, ELK and K8S now.