Need to fetch kuberentes yaml files from a filesystem instead of directly editing in the step

Hello.

We are planning to deploy applications to kubernetes via octopus deploy

We have tried using deploy kubernetes container step in octopus deploy .

But we don’t want to edit the yaml files directly there. Instead we want to store this yaml files in a filesystem and fetch it and deploy it .

Kindly suggest us on this.

We have tried with step deploy Raw kuberentes yaml step during process in project. We have tried with octopus built in option and had to mention the package.and upload package. Instead if there’s any option to mention path where our yaml files are stored on octopus deploy server .

Kindly let us know if this is feasible

Hi @kakarlayogitha,

Thanks for reaching out!

There are a few options you can use to achieve this. Unfortunately, the built-in Kubernetes steps like “Deploy a Kubernetes Container” and “Deploy raw Kubernetes YAML” require you to either have the yaml in the in-line source code or pulled from a package.

Depending on how you operate, if you check your YAML files into GitHub, you could use the GitHub Feed option to pull the YAML files (assuming the correct tags are used).

The other option would be to use the “Run a Kubectl CLI script” step, where you can script out your Kubernetes deployment yourself and use a project variable to store the path to the YAML file, allowing you to store the files using a local file-store, like below:

I hope this helps! Please let me know if you have any questions or if you run into any issues.

Kind Regards,
Adam

Hello,

Thanks for a quick update.

Kindly request you to explain on this step to use the “Run a Kubectl CLI script” step

Where can we add our YAML file and their relative path /location .If we have our YAML files in one servers location, then how can we add that path .Please suggest

Hi @kakarlayogitha,

Depending on where you’re running Kubernetes will determine how you need to configure the YAML files.

Could you give me a high-level overview of what you’re trying to achieve?

For instance;

  • You’re running Kubernetes on a Tentacle or Worker.
  • You’re using a cloud service to host and deploy Kubernetes containers.
  • You’re running Kubernetes on the Octopus Server.

This will help me better provide you with advice on how to proceed.

Kind Regards,
Adam

Hi

currently as POC , i am running Kubernetes on the Octopus Server.

Later we will run on Worker nodes itself

Please suggest

Hi @kakarlayogitha,

If you’re running Kubernetes on the Octopus Server then at the moment you can use a project variable to store the file-path of the YAML files on the Octopus Server.

Inside your project, go to Variables → Project:
image

Then, create a variable with a memorable name and set the value to the file path for your Kubernetes YAML file.

You can then use the “Insert a Variable” button to place this variable directly into the Inline Source Code of the 'Deploy a Kubectl CLI script" step, which Octopus will then use at deployment.

When you come to use workers to run Kubernetes, you would likely have to either have the YAMLs stored on the workers and use the file-path to the files as the variable value or you would need to provide your workers with access to a file share and use the file share path as the variable value.

I hope this helps, let me know if you have any further questions.

Kind Regards,
Adam

1 Like

Hello,

Thanks for quick Update . I am trying the same in my env.

I would like to ask which is the best practise which we can follow to deploy our yaml files (applications) into kubernetes cluster (EKS)

please suggest

Hi @kakarlayogitha,

The best practice would likely be to store your YAML file inside a package and then store the package either in an external feed (GitHub) or in the Octopus Built-In feed.

This way you could use the “Deploy raw Kubernetes YAML” step to deploy the Kubernetes containers.

You can push packages to the built-in feed via command line or the user interface, our docs explain this better than I can, which you can view here: Built-In Octopus Repository.

If you update your YAML by updating the package and pushing a new package version to the built-in feed or an external feed, when you next create a release you can configure the release to use the latest version of the package, allowing you to dynamically update YAML configuration without having to edit the project process.

As your end goal is deploying to EKS, this blog post about configuring an EKS cluster inside Octopus may be useful to read: Creating an EKS cluster with eksctl.

Kind Regards,
Adam

Hello,

we have tried this Octopus built in feed and used “Deploy raw Kubernetes YAML” step to deploy kubernetes containers. But every time we need to upload the package right ? and what if we need to have backup of that package ?

In our case we do not want to use external feeds like Github

Hi @kakarlayogitha,

You will only have to upload a new package if you need to make changes to it.

During the deployment step, the package is pushed onto the worker machine only if it doesn’t already exist on the machine.

Therefore, the package should remain cached if already deployed to a worker previously with no changes to the package/YAML.

Kind Regards,
Adam

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