{"id":15790625,"url":"https://github.com/ericklv/gcp-schedule-gke","last_synced_at":"2025-03-31T18:43:30.906Z","repository":{"id":248766269,"uuid":"829645915","full_name":"ericklv/gcp-schedule-gke","owner":"ericklv","description":null,"archived":false,"fork":false,"pushed_at":"2024-07-17T00:41:44.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-11T22:18:24.242Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ericklv.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2024-07-16T21:20:35.000Z","updated_at":"2024-07-17T00:41:47.000Z","dependencies_parsed_at":"2024-07-17T02:11:13.927Z","dependency_job_id":null,"html_url":"https://github.com/ericklv/gcp-schedule-gke","commit_stats":null,"previous_names":["ericklv/gcp-schedule-gke"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericklv%2Fgcp-schedule-gke","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericklv%2Fgcp-schedule-gke/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericklv%2Fgcp-schedule-gke/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ericklv%2Fgcp-schedule-gke/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ericklv","download_url":"https://codeload.github.com/ericklv/gcp-schedule-gke/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246521912,"owners_count":20791222,"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":[],"created_at":"2024-10-04T22:22:03.473Z","updated_at":"2025-03-31T18:43:30.883Z","avatar_url":"https://github.com/ericklv.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Requirements\nTo run needs golang \u003e= 1.22 and Gcloud SDK. Your account must have Kubernetes Engine Cluster Admin permissions.\n\n# Previous\nYou need a cluster configured, when you send `down` as param this code reduce to 0 replicas all deployments in one namespace. Is necesary all deployments associated with an environment must have the nodeSelector in the same node-pool and namespace.\n\nWhe you send `up` as param, recreates a node pool and set all deployment replicas to 1\n\nIn this case you can create a node-pool, namespace and deployment with next steps:\n\n```bash\nkubectl config use-context ${your-gke-context}\nkubectl create namespace tiny-nspace\ngcloud container node-pools create tiny-pool --cluster ${your-cluster} --machine-type=g1-small --disk-size=20 --num-nodes=1 --zone ${cluster-zone} --async\nkubectl apply -f ./nginx-deployment.yaml \n```\n\n# Test \nTo run in local use (default port is 5432): \n```bash\ngo mod tidy\ngo run main.go\n```\n\n# Request\nSend a `POST` method to `${your-domain}/k8s/:action` where `:action` can be `down` or `up`\n\n## Body Examples\n### Down\n```JSON\n{\n\t\"cluster\": \"tiny-cluster\",\n\t\"zone\": \"us-central1-a\",\n\t\"project\": \"tiny-project\",\n\t\"namespace\": \"tiny-nspace\",\n\t\"nodepool\": \"tiny-pool\"\n}\n```\n\n### Up\n\n```JSON\n\t\"cluster\": \"tiny-cluster\",\n\t\"zone\": \"us-central1-a\",\n\t\"project\": \"tiny-project\",\n\t\"namespace\": \"tiny-nspace\",\n\t\"nodepool\": \"tiny-pool\",\n\t\"machineSpecs\": {\n\t\t\"type\": \"g1-small\",\n\t\t\"disk\": \"20\",\n\t\t\"numNodes\": \"1\"\n}\n```\n\n# Schedule\n\n1. Configure a google account service in GCP and add Kubernetes Engine Cluster Admin permissions.\n2. Generate a key file as JSON [Ref](https://cloud.google.com/sdk/gcloud/reference/auth/activate-service-account). \n3. Update Dockerfile with this values.  \n   - `key-file` is your JSON  \n   - `project` is project-id of instances.\n   - `activate-service-account` is your google account service.\n\nAdd your `cloudbuild.yaml`, configure a Cloud Build Trigger and deploy as Cloud Run, use Cloud Schdeuler to call API when you need.\n\n\nGood luck, have fun.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericklv%2Fgcp-schedule-gke","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fericklv%2Fgcp-schedule-gke","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fericklv%2Fgcp-schedule-gke/lists"}