Kubectl kustomize overlays/pri-dev is failing

i am running below commands in powershell script

kubectl version
kubectl version --short
kubectl kustomize overlays/pri-dev
kubectl apply -k overlays/pri-dev

overlay/dev.yaml

resources:

  • …/…/base

patchesStrategicMerge:

  • dev.yaml

configMapGenerator:

  • name: sample-web-api2-appsettings-config
    files:
    • appsettings-config=configs/appsettings.dev.json

Hi @venkat.vnextapps,

Thanks for reaching out to Octopus Support!

I’ve taken a look over the error message you’ve sent across as well as all the details and screenshots.

It looks as though the error message you’re receiving is due to Octopus targeting a directory path as a resource as opposed to a file.
The filepath “…/…/base” appears to be a directory, per the screenshots you’ve shared.

I wonder if it would be worth using an absolute file path to the file you’re looking to target for the resource, for instance, if the file is base/kustomization.yaml, you can use the octostache variable for the work directory:
#{Octopus.Action.Package[PACKAGE_NAME].ExtractedPath}\base\kustomization.yaml

I believe it could be worth testing with the above value, substituting the package name with the name of your referenced package.

Please let me know if you’re able to try the above and what the results are if you can, or if you have any questions/concerns.

Kind Regards,
Adam

Thanks for you reply, yaml file is not liking the variable ,getting below warning
Incorrect type. Expected “string”.yaml-schema: kustomization.yaml

Hi @venkat.vnextapps,

My apologies, I was under the belief that the setting for the resource that was erroring was a setting inside of Octopus, having not seen the full task log.

In order to use variables inside these files, you would have to enable substitution variables or structured configuration variables.

Ultimately, it appears as though the format for what you’re looking to achieve isn’t quite what kubernetes is expecting.
Does the kubectl script work as expected when run outside of Octopus with “…/…/base” set as the resource in the yaml?
If it doesn’t run successfully, it may be best to refer to kubernetes documentation for the expected formatting for what you’re looking to achieve.

Kind Regards,
Adam

The same scripts are working when I run it in my local, yes Kubernetes recommends using …/…/base for overlays.
here is the output when I ran this script in my local


Hey @venkat.vnextapps,

Thanks for clarifying and for the extra information.

As you’re pointing to the …/…/base directory, I assume that you want multiple items to be added as a resouce.

Would you be able to try listing each individual item you require inside the base folder as a resource on the overlay? Something like:

resources:
 - ../../base/item1.yaml
 - ../../base/item2.xyz

Please let me know the outcome of this test or if you run into any errors.

Kind Regards,
Adam

This approach is not working

apiVersion: kustomize.config.k8s.io/v1beta1

kind: Kustomization

resources:

  • …/…/base/kustomization.yaml

patchesStrategicMerge:

  • dev.yaml

configMapGenerator:

  • name: sample-web-api2-appsettings-config

files:

  • appsettings-config=configs/appsettings.dev.json

We are doing a POC to see if I can deploy the apps from octopus to k8 using this approach but this is a big blocker for us to use it.
Is there any way to update the kubectl cli in the worker , I see its too old and that could be the reason for this error.

Hey @venkat.vnextapps,

When it comes to the tooling on our cloud workers, the tooling on the machines as standard can sometimes be out of date.

The reason for this is that we stopped updating the tooling installed on our workers, there were beginning to get a large number of tools and keeping them up to date on all of our workers is a continuously moving target.

To remedy this, we introduced execution containers, as well as a worker-tools image that we update frequently.
It could be worth attempting to use an execution container to run this process, to see if the higher kubectl version allows a successful deployment.

When setting up the execution container, you must first create a docker feed, and then use the following as the container:
Windows: octopusdeploy/worker-tools:4.0.0-windows.ltsc2019
Ubuntu: octopusdeploy/worker-tools:4.0.0-ubuntu.18.04

Please let me know how this goes and if it gets you any further in your deployment.

Kind Regards,
Adam

i made changes in the yaml files to use the lower version settings in the Kustomization kind and its working now, thanks.

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
namespace: default
bases:

  • ./sample-web-api
  • ./sample-web-api-networking
1 Like

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