Skip to content

thatmlopsguy/github-repo-operator-ansible

Repository files navigation

GitHub Repo Operator (Ansible Operator SDK)

Overview

This project is a Kubernetes Operator for managing GitHub repositories, built using the Ansible Operator SDK. It enables you to declaratively create, update, and delete GitHub repositories directly from your Kubernetes cluster by defining custom resources.

⚠️ Educational Use Only

This project is for educational purposes only and should not be used in production environments. It is designed to demonstrate Kubernetes operator development concepts and GitHub API integration patterns. For production use cases, consider using established solutions like crossplane provider-upjet-github.

Features

  • Declarative management of GitHub repositories via Kubernetes Custom Resources
  • Automated repository creation, updates, and deletion
  • Leverages Ansible playbooks for GitHub API interactions

Prerequisites

  • Kubernetes cluster (v1.31+ recommended)
  • Operator SDK
  • Ansible
  • GitHub personal access token with repo permissions

Installation

  1. Clone this repository:
git clone https://github.com/thatmlopsguy/github-repo-operator-ansible.git
cd github-repo-operator-ansible
  1. Build and deploy the operator to your Kubernetes cluster:
make install
make deploy
  1. Set your GitHub credentials as Kubernetes secrets or environment variables as required by the operator.

Usage

Create a GitHubRepo custom resource to manage a repository. Example:

apiVersion: github.thatmlopsguy.com/v1alpha1
kind: GitHubRepo
metadata:
    name: example-repo
spec:
    name: example-repo
    description: "Managed by Kubernetes!"
    private: true

Apply the resource:

kubectl apply -k config/samples

The operator will reconcile the state and ensure the repository exists in your GitHub account.

Bootstrapping the Project

To set up this project from scratch, follow these steps:

  1. Install Operator SDK

Use the provided script to install the latest operator-sdk binary

bash scripts/install-operator-sdk.sh
  1. Initialize the Operator Project

Run the following command to bootstrap the operator-sdk project with the Ansible plugin:

operator-sdk init --domain=thatmlopsguy.com --plugins=ansible --project-version=3

This will scaffold the necessary files and directories for an Ansible-based Kubernetes operator.

Contributing

Contributions are welcome! Please open issues or pull requests for improvements and bug fixes.

License

This project is licensed under the MIT License. See the LICENSE file for details.