A Kubernetes controller for managing RolloutGate resources with GitHub integration. This controller implements a GitHub gate class that reports deployment status to GitHub's Deployments API and manages deployment dependencies.
- GitHub Deployment Integration: Creates and manages GitHub deployments for RolloutGate resources
- Dependency Management: Reads GitHub deployment statuses to determine allowed versions based on successful deployments
- Annotation-based Configuration: Uses annotations for GitHub-specific configuration
- Status Reporting: Reports deployment status back to GitHub Deployments API
The controller integrates with the existing RolloutGate API from the rollout-controller and extends it with GitHub-specific functionality:
┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐
│ RolloutGate │ │ GitHub Rollout │ │ GitHub Deploy │
│ (CRD) │───▶│ Gate Controller │───▶│ API │
└─────────────────┘ └─────────────────┘ └─────────────────┘
│
▼
┌─────────────────┐
│ Dependency │
│ Resolution │
└─────────────────┘
The controller uses annotations on the RolloutGate resource for GitHub-specific configuration:
apiVersion: kuberik.com/v1alpha1
kind: RolloutGate
metadata:
name: github-gate
annotations:
kuberik.com/gate-class: "github"
kuberik.com/github-repo: "myorg/myapp"
kuberik.com/deployment-name: "myapp-production"
kuberik.com/environment: "production"
kuberik.com/ref: "main"
kuberik.com/description: "Production deployment"
kuberik.com/auto-merge: "true"
kuberik.com/dependencies: "myapp-staging,myapp-testing"
kuberik.com/required-contexts: "ci,security-scan"
spec:
rolloutRef:
name: myapp-rollout
passing: truekuberik.com/gate-class: Must be set to "github" to enable GitHub gate functionalitykuberik.com/github-repo: GitHub repository in format "owner/repo"kuberik.com/deployment-name: Name of the current deployment
kuberik.com/environment: GitHub deployment environment (default: "production")kuberik.com/ref: Git reference (branch, tag, or SHA)kuberik.com/description: Description for the deploymentkuberik.com/auto-merge: Whether to automatically merge the deploymentkuberik.com/dependencies: Comma-separated list of deployment dependencieskuberik.com/required-contexts: Comma-separated list of required status check contextskuberik.com/github-token: Name of the secret containing GitHub token (default: "github-token")
The controller requires a GitHub token to authenticate with the GitHub API. Create a secret with the token:
apiVersion: v1
kind: Secret
metadata:
name: github-token
namespace: default
type: Opaque
data:
token: <base64-encoded-github-token>- The referenced
Rolloutmust have deployment history with aRevisionfield in theVersionInfostructure - If the revision is not available, the controller will fail with an error message
-
Gate Detection: The controller identifies RolloutGate resources with
kuberik.com/gate-class: "github"annotation. -
Configuration Extraction: GitHub configuration is extracted from annotations.
-
GitHub Client: A GitHub client is created using the token from the specified secret.
-
Version Resolution: The controller gets the current version from the referenced Rollout's deployment history, using the
Revisionfield fromVersionInfo. If the revision is not available, the controller will error out as it's required for GitHub deployments. -
Deployment Creation: A GitHub deployment is created or updated using the current version from the rollout.
-
Status Reporting: The deployment status is reported back to GitHub's Deployments API.
-
Dependency Resolution: If dependencies are specified, the controller checks GitHub deployment statuses to determine allowed versions based on successful deployments.
-
Version Management: Allowed versions are updated based on successful dependency deployments.
- Kubernetes cluster
- kubectl configured
- GitHub token with appropriate permissions
-
Install CRDs:
kubectl apply -f config/crd/bases/
-
Install the controller:
kubectl apply -k config/default/
-
Create GitHub token secret:
kubectl apply -f config/samples/github-token-secret.yaml
-
Create RolloutGate resources:
kubectl apply -k config/samples/
make buildmake testmake runtype RolloutGateSpec struct {
RolloutRef *corev1.LocalObjectReference `json:"rolloutRef"`
Passing *bool `json:"passing,omitempty"`
AllowedVersions *[]string `json:"allowedVersions,omitempty"`
GitHub *GitHubConfig `json:"github,omitempty"`
}type GitHubConfig struct {
Repository string `json:"repository"`
DeploymentName string `json:"deploymentName"`
Dependencies []string `json:"dependencies,omitempty"`
Environment string `json:"environment,omitempty"`
Ref string `json:"ref,omitempty"`
Description string `json:"description,omitempty"`
AutoMerge bool `json:"autoMerge,omitempty"`
RequiredContexts []string `json:"requiredContexts,omitempty"`
}type RolloutGateStatus struct {
GitHubDeploymentID *int64 `json:"githubDeploymentId,omitempty"`
GitHubDeploymentURL string `json:"githubDeploymentUrl,omitempty"`
LastSyncTime *metav1.Time `json:"lastSyncTime,omitempty"`
Conditions []metav1.Condition `json:"conditions,omitempty"`
}- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Submit a pull request
Apache 2.0