Passing manifest file from remote url with kubectl command

11/27/2018

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.

-- Ram
kubectl
kubernetes

1 Answer

11/27/2018

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 -
-- Emruz Hossain
Source: StackOverflow