{"id":18579697,"url":"https://github.com/jayantkatia/docker-kubernetes-101","last_synced_at":"2025-04-10T10:31:37.154Z","repository":{"id":117412868,"uuid":"542560129","full_name":"jayantkatia/docker-kubernetes-101","owner":"jayantkatia","description":"🐳🚢 GitHub Action workflows for Kubernetes and Docker","archived":false,"fork":false,"pushed_at":"2022-09-29T16:52:54.000Z","size":16882,"stargazers_count":14,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-24T19:45:44.740Z","etag":null,"topics":["docker","dockerhub","github-actions","kubernete"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jayantkatia.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}},"created_at":"2022-09-28T11:39:53.000Z","updated_at":"2024-08-21T10:13:06.000Z","dependencies_parsed_at":"2024-01-18T09:06:21.457Z","dependency_job_id":"c76d3909-0a9d-46a8-9cc9-6b04a582ee3c","html_url":"https://github.com/jayantkatia/docker-kubernetes-101","commit_stats":null,"previous_names":["jayantkatia/actions-for-docker","jayantkatia/actions-for-kubernetes-docker"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayantkatia%2Fdocker-kubernetes-101","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayantkatia%2Fdocker-kubernetes-101/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayantkatia%2Fdocker-kubernetes-101/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jayantkatia%2Fdocker-kubernetes-101/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jayantkatia","download_url":"https://codeload.github.com/jayantkatia/docker-kubernetes-101/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248199136,"owners_count":21063641,"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":["docker","dockerhub","github-actions","kubernete"],"created_at":"2024-11-06T23:41:50.891Z","updated_at":"2025-04-10T10:31:36.662Z","avatar_url":"https://github.com/jayantkatia.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n  \u003ch1\u003e🐳🚢 Docker-Kubernetes-101\u003c/h1\u003e\n\n  \u003ca href=\"\"\u003e![Workflow](https://img.shields.io/github/workflow/status/jayantkatia/docker-kubernetes-101/Build%20and%20Publish%20Container%20Image?style=for-the-badge)\u003c/a\u003e\n  \u003ca href=\"\"\u003e![License](https://img.shields.io/github/license/jayantkatia/docker-kubernetes-101?style=for-the-badge)\u003c/a\u003e\n  \u003ca href=\"\"\u003e![Issues](https://img.shields.io/github/issues/jayantkatia/docker-kubernetes-101?style=for-the-badge)\u003c/a\u003e\u003cbr/\u003e\n  \n  Learnings and approach for deployments using Docker and Kubernetes.  \n\u003c/div\u003e\n\n## ✍️ Approach\n### ✔️ Fork sub-directory from kubernetes/examples\nTo fork [kubernetes/examples/guestbook-go](https://github.com/kubernetes/examples/tree/master/guestbook-go) directory,\n```sh\ngit clone https://github.com/kubernetes/examples.git\ncd examples\ngit subtree split --prefix=guestbook-go -b main\ngit checkout main\n# create a GitHub repo\ngit remote set-url origin YOUR_NEW_GIT_LINK\ngit fetch -pa\ngit push -u origin main\n# clone the new repo\ncd ..\ngit clone YOUR_NEW_GIT_LINK\ncd YOUR_NEW_REPO\n```\n\n\u003e Since the forked repo had [Apache License 2.0](https://github.com/kubernetes/examples/blob/master/LICENSE), we persevere the [LICENSE](https://github.com/jayantkatia/actions-for-docker/blob/main/LICENSE)\n\n### ✔️ Prevent merging anything in main branch without review\nGitHub has some granular and configurable settings to [enable branch protection](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/defining-the-mergeability-of-pull-requests/managing-a-branch-protection-rule),\n```\nSettings:\n    - [x] Require a pull request before merging\n    - [x] Require approvals: 1 (testing purpose, do increase if required) \n    - [x] Dismiss stale pull request approvals when new commits are pushed\n    - [x] Require review from Code Owners (may include CODEOWNERS file)\n    - [ ] Do not allow bypassing the above settings (testing purpose)\n```\n\n### ✔️ Write GitHub action workflow \n```\nRequirements:\n    - Create a container image\n    - Push that image to DockerHub\n    - Build container image only when one of the below conditions is true,\n        - When PR get merged in main/master branch from any other branch\n        - When commit message contains `BUILD_CONTAINER_IMAGE` string\n```\n1. To build a container image use [docker's build-and-push GitHub action](https://github.com/marketplace/actions/build-and-push-docker-images)\n2. Create a token on DockerHub and add credentials to repository secrets. Refer [DockerHub Docs](https://docs.docker.com/docker-hub/access-tokens/)\n3. Add conditionals to action workflow\n```yaml\n...\non:\n  push:\n    branches: [main]\n  pull_request:\n    types:\n      - closed\n    branches:\n      - main\n\njobs:\n  build-publish-container-image:\n    if: github.event.pull_request.merged == true || contains(github.event.head_commit.message, 'BUILD_CONTAINER_IMAGE')\n```\n\n### ✔️ Deploy container image to Kubernetes cluster\n#### 🏡 Local Kubernetes Cluster using ```minikube```\n1. Install and run ```minikube```, Refer [Gettting started with minikube](https://minikube.sigs.k8s.io/docs/start/).\n    1. (Optional, Fedora specific steps) Prefer virtualization over containerization, due to known issues with btrfs and systemd.\n     ```sh\n     sudo dnf install @virtualization\n     sudo systemctl start libvirtd\n     sudo systemctl enable libvirtd\n     \n     # start minikube\n     minikube start --driver kvm2\n     ```\n     \n#### 🚂 Deployment\n1. Make sure that your image path is correct and pointing to your DockerHub container image in ```guestbook-controller.json```,\n```yaml\n ...\n \"spec\":{\n            \"containers\":[\n               {\n                  \"name\":\"guestbook\",\n                  \"image\":\"jayantkatia/actions-for-docker:latest\",\n                  ...\n               }\n             ]\n        }\n  ...\n```\n\n2. Run,\n```sh\nkubectl apply -f redis-master-controller.json\nkubectl apply -f redis-master-service.json\nkubectl apply -f redis-replica-controller.json\nkubectl apply -f redis-replica-service.json\nkubectl apply -f guestbook-controller.json\nkubectl apply -f guestbook-service.json\n```\n3. Run ```minikube tunnel``` to allocate an external IP to LoadBalancer.\n\n#### 🎉 Result\n![Screenshot from 2022-09-29 22-12-01](https://user-images.githubusercontent.com/56118625/193090218-643a3627-e389-43d1-a808-5b93cb0b77c2.png)\n![Screenshot from 2022-09-29 22-18-45](https://user-images.githubusercontent.com/56118625/193091071-e12b254f-0d27-4590-9c9a-da797bfb8d70.png)\n![Screenshot from 2022-09-29 22-22-25](https://user-images.githubusercontent.com/56118625/193091711-7cead1e3-be57-4de9-b79f-7d8b30681559.png)\n\n\n## ✨ Contributing\nYes, please! Feel free to contribute, raise issues and recommend best practices.\n\nA few resources to get you started:\n- [GitHub Actions Documentation](https://docs.github.com/en/actions)\n- [Docker Documentation](https://docs.docker.com/)\n- [MiniKube Documentation](https://minikube.sigs.k8s.io/docs/)\n- [Kubernetes and MiniKube Refresher](https://www.youtube.com/watch?v=s_o8dwzRlu4)\n\n\u003c!-- Comment to change code and test workflow: 6 --\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayantkatia%2Fdocker-kubernetes-101","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjayantkatia%2Fdocker-kubernetes-101","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjayantkatia%2Fdocker-kubernetes-101/lists"}