Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

make custom_env_var can reference the whole secret/configmap without using a slash #521

Merged

Conversation

qibobo
Copy link
Contributor

@qibobo qibobo commented Jun 26, 2020

This PR is to fix the issue we reported in #475 (comment).
@isutton
Could you take a look at this PR? It need to be rebased after your PR #515 is merged.

@openshift-ci-robot
Copy link
Collaborator

Hi @qibobo. Thanks for your PR.

I'm waiting for a redhat-developer member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@qibobo qibobo changed the title [WIP]make custom_env_var can reference the whole secret/configmap without using a - [WIP]make custom_env_var can reference the whole secret/configmap without using a slash Jul 6, 2020
@isutton
Copy link
Contributor

isutton commented Jul 13, 2020

@qibobo I've rebased #515 on upstream's master.

@qibobo qibobo force-pushed the dev_qy_secretName branch from 6a4cb89 to 38164bc Compare July 17, 2020 01:34
@qibobo qibobo changed the title [WIP]make custom_env_var can reference the whole secret/configmap without using a slash make custom_env_var can reference the whole secret/configmap without using a slash Jul 17, 2020
@qibobo qibobo force-pushed the dev_qy_secretName branch from 38164bc to a7b8dac Compare July 20, 2020 05:24
@qibobo
Copy link
Contributor Author

qibobo commented Jul 20, 2020

@isutton I have rebase the code with master and verified the feature works.
Test steps:
1 Add annotations:

metadata:
  annotations:
    servicebindingoperator.redhat.io/status.secretName: binding:env:object:secret
    servicebindingoperator.redhat.io/status.secretName-url: binding:env:object:secret

2 create knative service as application

cat <<EOF | kubectl apply -f -
apiVersion: serving.knative.dev/v1
kind: Service 
metadata:
  name: knative-vcap
spec:
  template:
    metadata:
      annotations:
        autoscaling.knative.dev/minScale: "1"
    spec:
      containers:
        - image: docker.io/qibobo/go4autoscaler:latest
          ports:
          - containerPort: 8080
EOF

3 Create SBR

cat <<EOF | kubectl apply -f -
apiVersion: apps.openshift.io/v1alpha1
kind: ServiceBindingRequest
metadata:
  name: binding-request-vcap
spec:
  applicationSelector:
    resourceRef: knative-vcap
    group: serving.knative.dev 
    version: v1 
    resource: services 
  backingServiceSelectors:
    - group: ibmcloud.ibm.com
      version: v1alpha1
      kind: Binding
      resourceRef: thetranslator5
      envVarPrefix: serviceprefix
  customEnvVar:
    - name: VCAP_SERVICES
      value: '{"language-translator":[{"credentials":{{json .v1alpha1.ibmcloud_ibm_com.Binding.thetranslator5.status.secretName}},"name":"thetranslator5","plan":"standard"}]}'
    - name: TRANSLATOR_NAME
      value: "thetranslator5"
    - name: URL
      value: '{{.v1alpha1.ibmcloud_ibm_com.Binding.thetranslator5.status.secretName.url}}'
EOF

4 Check env injection:

SERVICEPREFIX_SECRET_IAM_ROLE_CRN=crn:v1:bluemix:public:iam::::serviceRole:Manager
SERVICEPREFIX_SECRET_APIKEY=XXXXXX
SERVICEPREFIX_SECRET_IAM_SERVICEID_CRN=crn:v1:bluemix:public:iam-identity::a/ef6a34810cbcd892507d3ebe01e3d95a::serviceid:ServiceId-471aa3de-daac-483a-9364-42fe0854a353
SERVICEPREFIX_SECRET_IAM_APIKEY_DESCRIPTION=Auto-generated for key 6142fe4b-5a7d-4951-8c64-b70433b1ccd3
SERVICEPREFIX_SECRET_URL=https://api.us-south.language-translator.watson.cloud.ibm.com/instances/b6cff0d7-dcfb-467d-9f75-7a044b6b15fd
SERVICEPREFIX_SECRET_IAM_APIKEY_NAME=thetranslator5

VCAP_SERVICES={"language-translator":[{"credentials":{"apikey":"XXXXXX","iam_apikey_description":"Auto-generated for key 6142fe4b-5a7d-4951-8c64-b70433b1ccd3","iam_apikey_name":"thetranslator5","iam_role_crn":"crn:v1:bluemix:public:iam::::serviceRole:Manager","iam_serviceid_crn":"crn:v1:bluemix:public:iam-identity::a/ef6a34810cbcd892507d3ebe01e3d95a::serviceid:ServiceId-471aa3de-daac-483a-9364-42fe0854a353","url":"https://api.us-south.language-translator.watson.cloud.ibm.com/instances/b6cff0d7-dcfb-467d-9f75-7a044b6b15fd"},"name":"thetranslator5","plan":"standard"}]}
URL=https://api.us-south.language-translator.watson.cloud.ibm.com/instances/b6cff0d7-dcfb-467d-9f75-7a044b6b15fd

@isutton isutton self-assigned this Jul 23, 2020
@isutton
Copy link
Contributor

isutton commented Jul 23, 2020

/test

@openshift-ci-robot
Copy link
Collaborator

@isutton: The /test command needs one or more targets.
The following commands are available to trigger jobs:

  • /test 4.5-acceptance
  • /test 4.5-e2e
  • /test 4.5-lint
  • /test 4.5-unit
  • /test e2e
  • /test lint
  • /test unit

Use /test all to run all jobs.

In response to this:

/test

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@isutton
Copy link
Contributor

isutton commented Jul 23, 2020

/test all

@baijum
Copy link
Member

baijum commented Jul 23, 2020

/ok-to-test

@baijum
Copy link
Member

baijum commented Jul 23, 2020

/retest

@cdlliuy
Copy link
Contributor

cdlliuy commented Jul 24, 2020

@isutton , the test seems passed

@cdlliuy
Copy link
Contributor

cdlliuy commented Jul 30, 2020

@DhritiShikhar @isutton , can you help to review?

@isutton
Copy link
Contributor

isutton commented Jul 30, 2020

/lgtm
/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: isutton

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-merge-robot openshift-merge-robot merged commit 0b3bd14 into redhat-developer:master Jul 30, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants