Clone or Fork & Clone this GitHub repository to your local machine. Use Github Desktop. Once cloned, open the local repository folder in VS Code.
Install Docker for Windows from here. I have had more luck with the experimental version, not the stable version.
When working with containers, you will need a container registry as mandatory to store all your containers so that they are accessible by virtually everything, ACI, AKS etc etc. By default the docker tools use the Docker registry which can be found at http://hub.docker.com. However you can use the Azure Container Registry instead. Create a container registry using the Azure portal.
You will need the Azure based VS Code extensions as well as the Docker extension. Read the follow the directions in the Docker extension to setup your environment including connecting to the Azure Container Registry.
The Docker extension in VS Code takes care of all the manual Docker command work. Bring up the VS Code Command Palette (F1) integration for the most common Docker commands (for example docker build, docker push, etc.).
With the Docker extension, you can do practically all your common Docker image commands using VS Code.
-
Clone this repo:
git clone https://github.com/marckean/SHOUTcast-Linux.git
-
Open the folder in VS Code
-
Build the image. In VS Code, hit F1, then choose Docker: Build Image, then tag it with marcregistry.azurecr.io/shoutcast-linux:latest.
-
Then simply push the image to the Azure Container registry - using the Docker extension in VS Code (refer to screenshot above)
-
Create an Azure Resource Group
az group create --name 'SHOUTCAST-Linux' --location australiaeast
-
Create the container in Azure
az container create --resource-group 'SHOUTCAST-Linux' --name 'shoutcastlinux' --image marcregistry.azurecr.io/shoutcast-linux:latest --registry-username marcregistry --registry-password 'PaSsWoRd' --restart-policy OnFailure --ip-address Public --cpu 1 --memory 1 --ports 80 81 --location australiaeast --verbose
-
Show the container in Azure
az container show --resource-group 'SHOUTCAST-Linux' --name 'shoutcastlinux' --out table
- Using a popular media player, like Winamp, in Winamp hit CTRL-L, open the stream http://IP-AddressOfContainer
- Or with your favourite browser, simply navigate to the IP address of the container. Then click on listen.
You can bring up the VS Code Integrated Terminal from the View menu and run Docker commands locally if you wish.
docker build -t marcregistry.azurecr.io/shoutcast-linux:latest .
docker ps [-all]
See all containers that were previously run but that have exited and can be still committed to a new image layer
docker ps -a
docker commit
docker stop <container-name>
docker search microsoft
docker pull microsoft/iis
docker pull microsoft/windowsservercore:1709
docker pull marcregistry.azurecr.io/windowsservercore
docker exec -it 002 cmd
docker inspect 002
docker inspect -f "{{ .NetworkSettings.Networks.nat.IPAddress }}" marcregistry.azurecr.io/shoutcastwin
docker ps -a
docker commit
docker tag <IMAGE ID> mycontainerimage
docker images
docker rm 8b f2 002 b1
docker rm $(docker ps -a -q)
Before we can push an image to the registry we need to login. This can be done using the following command-line
docker login -u <username> -p <password> http://<registryname>-on.azurecr.io
Change the parameters above to suite your environment.
From this moment on, all commands that interact with the registry are authenticated. If you are using these commands as part of your build scripts it is wise to also use the logout command, so the credentials are never left open on the machine.
Once your container has been built and is in the container registry, you are ready to deploy it using Kubernetes.
Quick recap on Kubernetes:
-
Pods | A pod consists of one or more containers that are guaranteed to be co-located on the host machine and can share resources. Each pod in Kubernetes is assigned a unique IP address within the cluster, which allows applications to use ports without the risk of conflict.
-
Nodes | also known as Worker or Minion, is a machine where containers (workloads) are deployed. Every node in the cluster must run a container runtime such as Docker, as well as the below-mentioned components, for communication with master for network configuration of these containers
-
Kubelet | is responsible for the running state of each node, ensuring that all containers on the node are healthy. It takes care of starting, stopping, and maintaining application containers organised into pods as directed by the control plane. Kubelet monitors the state of a pod, and if not in the desired state, the pod re-deploys to the same node. Node status is relayed every few seconds via heartbeat messages to the master. Once the master detects a node failure, the Replication Controller observes this state change and launches pods on other healthy nodes.
-
Services | A Kubernetes service is a set of pods that work together, such as one tier of a multi-tier application. The set of pods that constitute a service are defined by a label selector. Kubernetes provides service discovery and request routing by assigning a stable IP address and DNS name to the service,and load balances traffic in a round-robin manner to network connections of that IP address among the pods matching the selector (even as failures cause the pods to move from machine to machine). By default a service is exposed inside a cluster (e.g. back end pods might be grouped into a service, with requests from the front-end pods load-balanced among them), but a service can also be exposed outside a cluster (e.g. for clients to reach frontend pods)
-
Volume | a local disk directory or a network disk
From here https://docs.microsoft.com/en-us/azure/aks/tutorial-kubernetes-deploy-application
Install the Windows Subsystem for Linux
az group create --name <ResourceGroupName> --location AustraliaEast
az aks create --resource-group <ResourceGroupName> --name <AKSName> --node-count 2 --generate-ssh-keys --location AustraliaEast
This take a while to complete.
az aks get-credentials --resource-group=<ResourceGroupName> --name=<AKSName>
kubectl create secret docker-registry <SECRET_NAME> --docker-server <REGISTRY_NAME>.azurecr.io --docker-email=<YOUR_EMAIL> --docker-username=<USERNAME> --docker-password <PASSWORD>
az acr list --resource-group ContainerRegistry --query "[].{acrLoginServer:loginServer}" --output table
az aks create --resource-group <ResourceGroupName> --name <AKS-Name> --node-count 2 --generate-ssh-keys --location AustraliaEast
az aks browse --resource-group <ResourceGroupName> --name <AKS-Name>
az aks get-credentials --resource-group=<ResourceGroupName> --name=<AKS-Name>
kubectl create secret docker-registry aks-secret20180105 --docker-server <registryname>.azurecr.io --docker-email=<email> --docker-username=<username> --docker-password <password>