why kubernetes Service Account does not have Access and unable to process REST query?

7/10/2019

i have a system which is running swagger-ui for testing REST queries and minikube for managing the containers of different query services. Now when i execute a POST request on swagger it throws this error:

  "timestamp": "2019-07-10T06:53:47.639+0000",
  "status": 500,
  "error": "Internal Server Error",
  "message": "Failure executing: POST at: https://10.96.0.1/apis/batch/v1/namespaces/default/jobs. Message: Forbidden!Configured service account doesn't have access. Service account may have been revoked. jobs.batch is forbidden: User \"system:serviceaccount:default:default\" cannot create resource \"jobs\" in API group \"batch\" in the namespace \"default\".",
  "path": "/workflows"
}

i have tried creating a role by the name of jobs in minikube dashboard but that did not work. i guess i have to define a service account with certain roles but i am unaware of it as i am naive to the domain of kubernetes. my query services include GET,POST,DELETE.

Here is how my POST query looks like :

{
  "jobs": [
    {
      "container": {
        "args": [
          "string"
        ],
        "command": "string",
        "image": "ingestion",
        "properties": {
          "scihub_username": "username",
          "scihub_password": "password",
          "producttype": "S2MSI2A",
          "platformname": "Sentinel-2",
          "footprint":"POLYGON((5.8664000 50.3276000,9.4623000 50.3276000,9.4623000 52.5325000,5.8664000 52.5325000,5.8664000 50.3276000))",
          "days_back": 7
        },
        "volumes": [
          {
            "mountPath": "/out_data",
            "name": "workspace"
          }
        ]
      },
      "jobName": "ingestion"
    }
  ],
  "workflowName": "ingestion_and_preprocessing"
}

How can i fix this error to properly execute the query?

-- rehan
kubernetes-dashboard
minikube
service-accounts
swagger-ui

1 Answer

12/31/2019

I hit this error when I had an empty kubectl config file...

-- Chris Stryczynski
Source: StackOverflow