Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

possible api permission issue? #1

Open
evillgenius75 opened this issue Nov 13, 2019 · 6 comments
Open

possible api permission issue? #1

evillgenius75 opened this issue Nov 13, 2019 · 6 comments

Comments

@evillgenius75
Copy link

I built and ran this on my 1.13.11 Cluster running in Azure Kubernetes Service. I get an error in the logs that it couldn't query the namespaces API. I installed the serviceaccount in the default namespace. Is there a specific role and rolebinding this code needs to query correctly?

Logs:

kubectl logs -f kube-schedule-scaler-858d5697c-rx82q
Traceback (most recent call last):
  File "/root/schedule_scaling/schedule_scaling.py", line 273, in <module>
    deploy_job_creator()
  File "/root/schedule_scaling/schedule_scaling.py", line 74, in deploy_job_creator
    deployments__to_scale = deployments_to_scale()
  File "/root/schedule_scaling/schedule_scaling.py", line 52, in deployments_to_scale
    for namespace in list(pykube.Namespace.objects(api)):
  File "/usr/local/lib/python3.5/dist-packages/pykube/query.py", line 133, in __iter__
    return iter(self.query_cache["objects"])
  File "/usr/local/lib/python3.5/dist-packages/pykube/query.py", line 123, in query_cache
    cache["response"] = self.execute().json()
  File "/usr/local/lib/python3.5/dist-packages/pykube/query.py", line 108, in execute
    r.raise_for_status()
  File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://10.0.0.1:443/api/v1/namespaces
Running the Jobs of the last 5 minutes
@amelbakry
Copy link
Owner

@evillgenius75 Yes, you need clusterrole and clusterrolebinding to work with the service account. I will create a helm chart for easy installation soon.

@ekarmazin
Copy link

ekarmazin commented Jan 23, 2020

I got clusterRole and clusterRoleBinding working on K8S v1.15.3, no more 403 error but got 404 instead. What should I check for this:

Deployment: web-1, Namespace: default, Replicas: 4, MinReplicas: None, MaxReplicas: None, Schedule: 10 18 * * *
Traceback (most recent call last):
  File "/root/schedule_scaling/schedule_scaling.py", line 274, in <module>
    stack_job_creator()
  File "/root/schedule_scaling/schedule_scaling.py", line 155, in stack_job_creator
    stacks__to_scale = stacks_to_scale()
  File "/root/schedule_scaling/schedule_scaling.py", line 127, in stacks_to_scale
    for stackset in StackSet.objects(api).filter(namespace=namespace):
  File "/usr/local/lib/python3.5/dist-packages/pykube/query.py", line 133, in __iter__
    return iter(self.query_cache["objects"])
  File "/usr/local/lib/python3.5/dist-packages/pykube/query.py", line 123, in query_cache
    cache["response"] = self.execute().json()
  File "/usr/local/lib/python3.5/dist-packages/pykube/query.py", line 108, in execute
    r.raise_for_status()
  File "/usr/local/lib/python3.5/dist-packages/requests/models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://10.96.0.1:443/apis/zalando.org/v1/namespaces/default/stacksets
Running the Jobs of the last 5 minutes

I am using it for my web-1 deployment as annotation:

apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  annotations:
    deployment.kubernetes.io/revision: "3"
    zalando.org/schedule-actions: '[{"schedule": "10 18 * * *", "replicas": "4"}]'

@ekarmazin
Copy link

@amelbakry any luck to check on this one, please?

@ezienecker
Copy link

Any progress on this?

@ekarmazin
Copy link

@ezienecker I found a working fork of this repo: https://github.com/citizensadvice/kube-schedule-scaler

@ezienecker
Copy link

Thanks works like a charm. In this provided repo there is no stackset and a complete example with the correct rbac.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants