jack
jack

Reputation: 833

Openshift Configmap : create and update command

I am writing sample program to deploy into Openshift with configmap. I have the following configmap yaml in the source code folder so when devops is setup, Jenkins should pick up this yaml and create/update the configs.

 apiVersion: v1
 kind: ConfigMap
 metadata:
  name: sampleapp
 data:  
  username: usernameTest
  password: passwordTest

However, I could not find the command that would create/update if the config already exist (similar to kubectl apply command). Can you help with the correct command which would create the Resource if the job is run for the first time and update if otherwise.

I also want to create/update the Services,Routes from the yaml files in the src repository.

Thanks.

Upvotes: 1

Views: 16988

Answers (2)

Springhills
Springhills

Reputation: 386

If you have configmap in yaml file or you store in some place you can do replace it.

oc replace --force -f config-map.yaml this will update the existing configmap (it actually deletes and creates a new one)

After this - I executed: oc set env --from=configmap/example-cm dc/example-dc

Upvotes: 3

Keerthivarman
Keerthivarman

Reputation: 111

you can use "oc apply" command to update the resources already exists.

Like below Example:

#oc process -f openjdk-basic-template.yml  -p APPLICATION_NAME=spring-rest -p SOURCE_REPOSITORY_URL=https://github.com/rest.git -p CONTEXT_DIR='' | oc apply -f-

service "spring-rest" configured
route "spring-rest" created
imagestream "spring-rest" configured
buildconfig "spring-rest" configured
deploymentconfig "spring-rest" configured

Upvotes: 3

Related Questions