{"id":22211371,"url":"https://github.com/narmidm/github-actions-kubernetes","last_synced_at":"2025-07-01T12:33:10.184Z","repository":{"id":265905912,"uuid":"896836312","full_name":"narmidm/github-actions-kubernetes","owner":"narmidm","description":"Automating CI/CD with GitHub Actions and Kubernetes","archived":false,"fork":false,"pushed_at":"2024-12-01T12:53:22.000Z","size":23,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-25T05:42:16.026Z","etag":null,"topics":["cicd","devops","github-actions","kubernetes"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/narmidm.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":"2024-12-01T12:28:38.000Z","updated_at":"2025-02-24T22:17:10.000Z","dependencies_parsed_at":"2024-12-01T13:35:38.658Z","dependency_job_id":"fd93fa3c-1396-4319-8e38-4adcbd28717d","html_url":"https://github.com/narmidm/github-actions-kubernetes","commit_stats":null,"previous_names":["narmidm/github-actions-kubernetes"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/narmidm/github-actions-kubernetes","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narmidm%2Fgithub-actions-kubernetes","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narmidm%2Fgithub-actions-kubernetes/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narmidm%2Fgithub-actions-kubernetes/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narmidm%2Fgithub-actions-kubernetes/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/narmidm","download_url":"https://codeload.github.com/narmidm/github-actions-kubernetes/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/narmidm%2Fgithub-actions-kubernetes/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262963297,"owners_count":23391789,"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":["cicd","devops","github-actions","kubernetes"],"created_at":"2024-12-02T20:23:38.351Z","updated_at":"2025-07-01T12:33:10.160Z","avatar_url":"https://github.com/narmidm.png","language":"JavaScript","readme":"# 🚀 GitHub Actions CI/CD with Kubernetes Deployment\n\nAutomate your CI/CD pipeline using GitHub Actions and deploy your application seamlessly to a Kubernetes cluster.\n\n![GitHub Actions and Kubernetes](https://your-image-url.com/github-actions-kubernetes.png)\n\n## 📋 Table of Contents\n\n- [Introduction](#introduction)\n- [Prerequisites](#prerequisites)\n- [Getting Started](#getting-started)\n  - [1. Fork or Clone the Repository](#1-fork-or-clone-the-repository)\n  - [2. Project Structure](#2-project-structure)\n  - [3. Configure Docker and Kubernetes Secrets](#3-configure-docker-and-kubernetes-secrets)\n  - [4. Set Up GitHub Actions Secrets](#4-set-up-github-actions-secrets)\n- [Usage](#usage)\n  - [1. Build and Push Docker Image](#1-build-and-push-docker-image)\n  - [2. Deploy to Kubernetes](#2-deploy-to-kubernetes)\n  - [3. Test the Application](#3-test-the-application)\n- [Step-by-Step Commands](#step-by-step-commands)\n- [Contributing](#contributing)\n- [License](#license)\n\n---\n\n## Introduction\n\nThis repository contains a sample Node.js application that demonstrates how to set up a CI/CD pipeline using GitHub Actions to build and deploy to a Kubernetes cluster. By following this guide, you'll learn how to automate your deployments and ensure your applications are always up-to-date.\n\n## Prerequisites\n\nBefore you begin, make sure you have the following installed and set up:\n\n- **Git**: For cloning and managing repositories.\n- **Docker**: To build and manage container images.\n- **Node.js and NPM**: For running the Node.js application.\n- **kubectl**: Kubernetes command-line tool to interact with your cluster.\n- **A Kubernetes Cluster**: Can be local (Minikube) or cloud-based (GKE, EKS, AKS).\n- **GitHub Account**: To fork the repository and set up GitHub Actions.\n- **Docker Hub Account**: To push Docker images.\n\n## Getting Started\n\n### 1. Fork or Clone the Repository\n\n#### **Option A: Fork the Repository**\n\n1. Navigate to the [repository](https://github.com/your-username/github-actions-kubernetes).\n2. Click on the **\"Fork\"** button at the top right to create a copy under your GitHub account.\n\n#### **Option B: Clone the Repository**\n\n```bash\ngit clone https://github.com/your-username/github-actions-kubernetes.git\n```\n\nChange directory into the project folder:\n\n```bash\ncd github-actions-kubernetes\n```\n\n### 2. Project Structure\n\nHere's the layout of the repository:\n\n```\ngithub-actions-kubernetes/\n├── .github/\n│   └── workflows/\n│       └── ci-cd.yaml          # GitHub Actions workflow\n├── .gitignore                  # Files and directories to ignore in Git\n├── README.md                   # Project documentation\n├── app.js                      # Node.js application code\n├── package.json                # NPM configuration file\n├── package-lock.json           # NPM lock file\n├── Dockerfile                  # Docker configuration\n├── deployment.yaml             # Kubernetes Deployment manifest\n└── service.yaml                # Kubernetes Service manifest\n```\n\n### 3. Configure Docker and Kubernetes Secrets\n\n#### **Docker Hub**\n\n1. **Log In to Docker Hub:**\n\n   ```bash\n   docker login\n   ```\n\n2. **Create a Personal Access Token (Recommended):**\n\n  - Go to Docker Hub \u003e **Account Settings** \u003e **Security**.\n  - Click **New Access Token**, name it, and copy the token.\n\n#### **Kubernetes Config**\n\n1. **Get Your Kubeconfig File:**\n\n  - Typically located at `$HOME/.kube/config`.\n\n2. **Base64 Encode the Kubeconfig:**\n\n   ```bash\n   cat $HOME/.kube/config | base64 | pbcopy  # For macOS\n   ```\n\n   **Note:** On Windows, you can use:\n\n   ```bash\n   type %USERPROFILE%\\.kube\\config | base64 | clip\n   ```\n\n### 4. Set Up GitHub Actions Secrets\n\n1. **Navigate to Your Forked Repository on GitHub.**\n\n2. **Go to Settings \u003e Secrets and variables \u003e Actions.**\n\n3. **Add the Following Secrets:**\n\n  - **`DOCKERHUB_USERNAME`**: Your Docker Hub username.\n  - **`DOCKERHUB_TOKEN`**: Your Docker Hub password or access token.\n  - **`KUBE_CONFIG_DATA`**: The base64 encoded kubeconfig file.\n\n## Usage\n\n### 1. Build and Push Docker Image\n\n**Note:** The GitHub Actions workflow will automate these steps, but you can also do them manually.\n\n#### **Build the Docker Image:**\n\n```bash\ndocker build -t your-dockerhub-username/hello-kubernetes:latest .\n```\n\n#### **Push the Image to Docker Hub:**\n\n```bash\ndocker push your-dockerhub-username/hello-kubernetes:latest\n```\n\n### 2. Deploy to Kubernetes\n\n**Apply Kubernetes Manifests:**\n\n```bash\nkubectl apply -f deployment.yaml\nkubectl apply -f service.yaml\n```\n\n### 3. Test the Application\n\n1. **Get the Service IP:**\n\n   ```bash\n   kubectl get services\n   ```\n\n2. **Access the Application:**\n\n  - Navigate to the external IP in your browser.\n  - You should see **\"Hello, Kubernetes!\"** displayed.\n\n## Step-by-Step Commands\n\nHere's a consolidated list of commands to set up and run the project.\n\n### **Clone the Repository**\n\n```bash\ngit clone https://github.com/your-username/github-actions-kubernetes.git\ncd github-actions-kubernetes\n```\n\n### **Install Dependencies**\n\n```bash\nnpm install\n```\n\n### **Run the Application Locally**\n\n```bash\nnode app.js\n```\n\nVisit `http://localhost:3000` to test.\n\n### **Build the Docker Image**\n\n```bash\ndocker build -t your-dockerhub-username/hello-kubernetes:latest .\n```\n\n### **Run the Docker Container Locally**\n\n```bash\ndocker run -p 3000:3000 your-dockerhub-username/hello-kubernetes:latest\n```\n\n### **Push the Docker Image**\n\n```bash\ndocker push your-dockerhub-username/hello-kubernetes:latest\n```\n\n### **Deploy to Kubernetes**\n\n```bash\nkubectl apply -f deployment.yaml\nkubectl apply -f service.yaml\n```\n\n### **Check Deployment Status**\n\n```bash\nkubectl get deployments\nkubectl get services\nkubectl get pods\n```\n\n### **Set Up GitHub Actions Secrets**\n\n1. **Access Repository Settings on GitHub.**\n\n2. **Add Secrets:**\n\n  - **DOCKERHUB_USERNAME**\n  - **DOCKERHUB_TOKEN**\n  - **KUBE_CONFIG_DATA**\n\n### **Trigger GitHub Actions Workflow**\n\n- **Push Changes to GitHub:**\n\n  ```bash\n  git add .\n  git commit -m \"Your commit message\"\n  git push origin main\n  ```\n\n- The GitHub Actions workflow will automatically run on pushes to the `main` branch.\n\n## Contributing\n\nContributions are welcome! Please open an issue or submit a pull request for any improvements or suggestions.\n\n### **Steps to Contribute:**\n\n1. **Fork the Repository.**\n\n2. **Create a New Branch:**\n\n   ```bash\n   git checkout -b feature/your-feature-name\n   ```\n\n3. **Make Your Changes and Commit:**\n\n   ```bash\n   git commit -m \"Add your message\"\n   ```\n\n4. **Push to Your Forked Repository:**\n\n   ```bash\n   git push origin feature/your-feature-name\n   ```\n\n5. **Open a Pull Request on GitHub.**\n\n## License\n\nThis project is licensed under the Apache License Version 2.0- see the [LICENSE](LICENSE) file for details.\n\n---\n\n**Feel free to reach out if you have any questions or need further assistance!**\n\n# 😊 Happy Coding!\n\n---\n\n## Additional Resources\n\n- [GitHub Actions Documentation](https://docs.github.com/en/actions)\n- [Kubernetes Documentation](https://kubernetes.io/docs/home/)\n- [Docker Documentation](https://docs.docker.com/)\n\n---\n\n**Note:** Replace `your-username` and `your-dockerhub-username` with your actual GitHub and Docker Hub usernames respectively.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnarmidm%2Fgithub-actions-kubernetes","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnarmidm%2Fgithub-actions-kubernetes","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnarmidm%2Fgithub-actions-kubernetes/lists"}