4

I am trying to submit the resource to Container using Kubernetes CLI.

The below is what I use to submit jobs.

kubectl -n namespace create -f <manifest file PATH>

I am actually running this on a LINUX server which would meet application team requirement and provide this service for the users to use it.

The Challenge is I don't want to store the application teams Configuration files(.yml/.json) in the LINUX server and call it from the LOCALPATH instead call the configuration file remotely.

I think of BITBUCKET. Can someone please assist me on how we can call the file from remote location so that kubectl can accept it?

Appreciate your time and effort.

2 Answers 2

6

You can use pipe with kubectl command to achieve it.

For example,

curl <your file url> | kubectl apply -f -

Here is a working example:

curl https://gist.githubusercontent.com/hossainemruz/7926eb2660cc8a1bb214019b623e72ea/raw/d9505d06aee33e0144d9f2f9107290f1aba62cd5/mysql-initialization-with-init-container.yaml | kubectl apply -f -
Sign up to request clarification or add additional context in comments.

3 Comments

Thanks for your reply Emruz. I get the below error when I run the curl. curl --silent bitbucketdc.jpmchase.net/users/RAM/repos/KUBECTL/browse/… | kubectl apply -f - error: no objects passed to apply I think because BITBUCKET expects username and password
At first, make sure you are able to view the file using just cur <url>. your url does not provide the file while i try to curl. It gives me <a href="http://ww2.bitbucketdc.jpmchase.net">Moved Permanently</a>. you have to use raw url. if you only use curl to the file i have given in example, it will print the yaml in terminal.
Thanks Emruz i figured it out and curl is working well. Appreciate your timr
4

In case someone stumbles over this in the future, with the current version (v1.26.5+k3s1) of kubectl you can use

kubectl apply -f <url>

directly as long as the url returns raw text. For example raw.githubusercontent.com urls (what you get when you hit "raw" on the file viewer on GH) works.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.