Deploy multiple container into Azure

Good morning,

I am looking to deploy multiple containers into Azure something like:

  • Gateway / Proxy such as Traefik
  • Web service 1
  • Web service 2
  • Web service 3
  • Fake Database such postgreSQL

I have seen the example Deploy a app service container but this is a very simple container with a single service. I am looking for a more complex solution where I am deploying 10+ containers. I will probably use Azure Gateway in front of the container proxy, but would like to keep things as near to my Dev and test environments.

The workflow i am trying to achieve is locally deployments for DEV / TEST onto dedicated hosts running docker which is working without any issues. Then finally deploy into Azure for production using Octopus. I am currently using a private docker hub repository and would like to continue using this if possible. If this is not feasible I could use my CI to push the containers into an Azure registry but would like to avoid if possible. I would like a single source of truth for my containers (docker hub).

Any guides or guidance would be greatly appreciated.

Thanks

Hi @Keithmacan1,

Thanks for reaching out, welcome to the Octopus community!

We have a ton of great resources so I’ll try not to overload you with too much info all at once, but our blogs as you’ve found are a great place to start!

Common deployment patterns and how to use them in Octopus is great for showcasing different approaches to deployments with Octopus, while our samples instance has a ton of working examples of common real world setups.

For image sourcing, Octopus can definitely use private Docker registries and treats Docker images much like Packages which can be promoted through Lifecycles to control the flow from Dev through to Production. Multiple projects can be co-ordinated together for controlling more complex deployments.

I’ll leave it there for now but please let me know if you had any specific questions or would like any further recommendations!

(Also check out our Youtube channel which is great for a break from reading!)

Happy Deployments!

Thank you for the reply lots of information here.

I have gone down the Kubernetes route using AKS, I do have a question. What is the best way to expose the service in AKS from octopus.

I have a temporary fix with I am using a Kubernetes script and the powershell is as follows:

try {
 kubectl delete service $SERVICE_ANGULAR
}
catch { "" } 
try {
 kubectl expose deployment $SERVICE_ANGULAR
}
catch { "" }

Is there a better method start the service from Octopus that checks it exist and creates if required? I need to be able to let the proxy / gateway service communicate to the others, and why I exposing each of the service in the AKS internally?

Also what is the best way to deploy a new storage and mount the volume to a container?

Im looking to do something similar:

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: azure-managed-disk
spec:
  accessModes:
  - ReadWriteOnce
  storageClassName: managed-premium-retain
  resources:
    requests:
      storage: 5Gi

Thanks

Hi @Keithmacan1,

No problem at all, Kubernetes’s is a great choice!

We have a k8’s training series where we provide a walk-through building multi-environment deployments which I would recommend checking out however I definitely recommend looking at how we run Octopus on Kubernetes to see how our services are configured with Shared Storage and Load-balanced.

It includes all our recommendations for running our product, which seems very similar to your use case, and even includes the YAML for configuring services with plenty of tips thrown in too!

E.g. Exposing the SQL DB we create an ClusterIP Service:

apiVersion: v1
kind: Service
metadata:
  name: mssql
spec:
  type: ClusterIP
  ports:
    -
      port: 1433
      targetPort: 1433
      protocol: TCP
  selector:
    app: mssql

And for storage it’s often more cost effective to define shared storage to use:

kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: octopus-storage-claim
spec:
  accessModes:
    - ReadWriteMany
  storageClassName: azurefile
  resources:
    requests:
      storage: 4Gi

Feel free to reach out if you have any questions at all!

Best Regards,

Brilliant thanks for all your help on this.

Just one last question to deploy this in octopus what do i need to select?
Add Step → Kubernetes → then select ? (guessing deploy raw yaml) what happens if for example the storage already exists?

Hopefully I should be coming to you guys for a business license :slight_smile:

1 Like

Hey Keith,

Just jumping in for Finn as he won’t be online for a while.

Thanks for letting us know and you’re very welcome!

To answer your questions:

guessing deploy raw yaml - Correct, you’ll use Raw YAML in this case.

what happens if for example the storage already exists? - It will fail saying it already exists. Our step just uses kubectl commands and is a wrapper for them so any testing you want to do outside of Octopus with kubectl would translate to the same behavior within Octopus.

Please let me know if that helps or if you have any other questions!

Best,
Jeremy

If this is the case that it fails. What would be your suggestion or the best to handle if it already exist from within octopus. Is the best way to ignore the step if it fails and continue to the run the rest of the steps.

I had a chat with a colleague and we both agree that the best way to do this would be to create a step before it that checks if the storage exists, and based on the result, create an output variable that determines whether the “create persistant storage” step (You will need to separate that yaml out into its own step if you haven’t) runs.

Here is an example of something similar where our solutions team set up steps to check for existing Octopus nodes and deletes them if they exist: Octopus Deploy

Please let me know if that helps or if you have any questions!

Best,
Jeremy

Thanks Jeremy appreciate your assistance and answers.

My last and final question honestly. I have a package (library/packages) with some files that I would like to copy to the Persistent Storage in AKS any ideas?

Apologies if this is a stupid question and there is an article, but this is my final step. I have now 15+ containers all working in AKS all being deployed from my Local Octopus server :slight_smile:

Over the moon with it all.

Thanks again

Hey Keith,

You’re very welcome!

We had a quick chat and we think you can achieve this in a couple of ways. You would run either an Azure CLI step or a Kubectl step within Octopus and reference the package you want to upload to the persistent storage/pods. Then you would either use azcopy or kubectl cp(depending on the path you go down) to get those files to where you need them.

Sorry I don’t have too much more information than that, but hopefully that helps.

Please let me know if you get it going, you never know if someone will find your post and need the answer in the future!

Best,
Jeremy

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.