{"id":16766374,"url":"https://github.com/joyrex2001/nightshift","last_synced_at":"2025-03-17T02:31:25.194Z","repository":{"id":34544250,"uuid":"172787336","full_name":"joyrex2001/nightshift","owner":"joyrex2001","description":"Nightshift is an OpenShift service to scale deployments based on a predefined schedule.","archived":false,"fork":false,"pushed_at":"2025-03-13T06:57:38.000Z","size":16105,"stargazers_count":27,"open_issues_count":0,"forks_count":2,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-13T07:39:10.729Z","etag":null,"topics":["kubernetes","openshift"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/joyrex2001.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-02-26T20:42:35.000Z","updated_at":"2025-03-13T06:57:34.000Z","dependencies_parsed_at":"2024-03-17T10:29:48.399Z","dependency_job_id":"99744a86-6e79-49fd-9058-6ffebc8dfd73","html_url":"https://github.com/joyrex2001/nightshift","commit_stats":null,"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joyrex2001%2Fnightshift","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joyrex2001%2Fnightshift/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joyrex2001%2Fnightshift/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joyrex2001%2Fnightshift/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joyrex2001","download_url":"https://codeload.github.com/joyrex2001/nightshift/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243841125,"owners_count":20356440,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["kubernetes","openshift"],"created_at":"2024-10-13T06:06:11.386Z","updated_at":"2025-03-17T02:31:24.218Z","avatar_url":"https://github.com/joyrex2001.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Nightshift\n\n[![CircleCI](https://circleci.com/gh/joyrex2001/nightshift.svg?style=svg)](https://circleci.com/gh/joyrex2001/nightshift) [![Go Report Card](https://goreportcard.com/badge/github.com/joyrex2001/nightshift)](https://goreportcard.com/report/github.com/joyrex2001/nightshift)\n\nNightshift is a service that will enable automatic down and upscaling of\ndeployments within an OpenShift project at a predefined schedule. This in order\nto save resource usage (or use resources for something else). It will monitor\nand scale the namespaces according to a preset configuration.\n\n## Install in OpenShift\n\nNightshift can be run both from a seperate namespace, or in the namespace which\nit will schedule. In order to allow OpenShift scaling the services, it needs to\nrun with a service account that has both read and edit permissions on the\nnamespace it should control. Adding the service account can be done with the\nbelow commands, where a service account named \"nightshift\" is created in the\nproject specified with \"source\" which has access to the project \"target\". If\nmultiple projects should be scaled by nightshift, the policies should be added\nfor each project individually.\n\n```bash\noc create sa nightshift -n \u003csource\u003e\noc policy add-role-to-user view system:serviceaccount:\u003ctarget\u003e:nightshift -n \u003csource\u003e\noc policy add-role-to-user edit system:serviceaccount:\u003ctarget\u003e:nightshift -n \u003csource\u003e\n```\n\nThis repository also includes an example OpenShift template, which contains\nthe basis configuration for installing the service. The configuration is stored\nin a configmap, the example folder contains an example for this as well. The\ntemplate includes the OpenShift oauth proxy for authentication with an\nOpenShift account. Access is restricted to users that have update permissions\nin the project where nightshift is deployed. The example template pulls the\nnightshift image from docker hub.\n\n```bash\noc create configmap nightshift-config --from-file=examples/config.yaml\noc process -f examples/openshift.yaml | oc apply -f -\noc rollout latest dc/nightshift\n```\n\n## Configuration\n\nNightshift can be configured with both annotations, or via a config file. They\ncan also be combined, where annotations always override any other configuration\nset.\n\n### Schedule\n\nNightshift scales deployments according to a schedule. A schedule can be\nadded to a pod with an annotation, or can be defined in a config file. A\nschedule definition contains out of 3 elements; a section defining the day(s)\nin the week this schedule applies to, a time and the action that should be\ntaken.\n\nThe first section defines the day(s) of the week. This can be a combination\nof single day(s), a range of days, or both. Each day is specified by the first\nthree letters of the English name. If multiple days, or ranges are specified,\nthey should be seperated by a comma. A range is specified by two days seperated\nby a hyphen.\n\nThe second part defines the time. The time is specified in the timezone that\nhas been configured in the configuration file (default is Local, which usually\nequals to UTC in most deployments).\n\nThe last part defines the action that needs to be taken in this time event. At\nthis point only the number of replicas can be specified.\n\nAn example of a schedule configuration is: ```Mon-Wed,Fri 9:00 replicas=1```.\n\n#### Saving and restoring states\n\nNext to specifying the exact number of replicas, it is also possible to save\nand restore states. In order to do this, the ```state=save``` or ```state=restore```\ncan be added to the schedule. When the state should be saved, it will be saved\nbefore actual scaling to the number of replicas. When restoring the state, if\nno state is available, it will take the number of replicas that has been\n(optionally) specified in the schedule. The saved state will take precedence\non the number that is set in replicas if both are configured.\n\n#### Statefulsets\n\nBy default the scanner will only scan deploymentconfigs. Statefulsets are\nsupported as well by use of the ```statefulset``` scanner. This can be configured\nby specifying the ```type``` of the scanner in the scanner configuration\nsection. The default is ```openshift``` which scans for deploymentconfigs.\n\n### Annotations\n\nNightshift can be configured by both a configuration file, as well as\nannotations that should be set on a DeploymentConfig. These annotations will\nalways override the configuration specified in the configuration file. The\nannotations supported by nightshift are:\n\n* ```joyrex2001.com/nightshift.schedule``` in which a schedule can be specified.\nMultiple schedules are allowed, and should be seperated with a semicolon.\n* ```joyrex2001.com/nightshift.ignore``` which can be set to ```true``` to\nignore this deployment.\n\n### Configuration file\n\nThe most flexible way to configure nightshift is by using a configuration file.\nThe configuration file allow complex schedules, with both default schedules as\nwell as allowing to fix schedules for certain label criteria, specified with\na selector.\n\nIn the below example , namespace ```development``` will be scanned for\nannotations. If a deployment in this namespace doesn't have any schedule\nannotations, it will apply the default schedule. For a deployment that matches\nthe label ```app=shell```, no schedule will be applied at all.\n\n```\nscanner:\n  - namespace:\n      - \"development\"\n    default:\n      schedule:\n        - \"Mon-Fri  9:00 replicas=1\"\n        - \"Mon-Fri 18:00 replicas=0\"\n    deployment:\n      - selector:\n          - \"app=shell\"\n        schedule:\n          - \"\"\n```\n\nThe scanner configuration will be handled top down. If a pod is found in\nmultiple scanner configurations, only the last one will be applied.\n\nSee the examples folder for another example, which also includes basic\nnightshift configuration.\n\n## Triggers\n\nNightshift is able to trigger events when it will scale. This is done by\ntriggers. Currently there is only one type of trigger \"webhook\", which will\ncall a http endpoint with a predefined configuration.\n\nTriggers can only be configured in the configuration file. Each trigger has an\nid which can be used in the schedule definition to execute the trigger. When\nat a certain time, the endpoint is referenced by multiple schedules, it will be\ncalled only once.\n\nAn detailed reference example can be found in the examples folder in the\nfile ```triggers.yaml```.\n\n\n## Prometheus metrics\n\nWhen the web interface is enabled, prometheus metrics will be available as well.\nThe endpoint of the metrics is ```/metrics```. If an id is set for the schedule\ndefinitions, the current number of applied replicas for that schedule is\nreflected in the ```nightshift_replicas``` metric, and can be used to e.g.\ndisable alerting when nightshift downscaled the pods as planned.\n\n## See also\n\n* https://hub.docker.com/r/joyrex2001/nightshift\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoyrex2001%2Fnightshift","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoyrex2001%2Fnightshift","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoyrex2001%2Fnightshift/lists"}