Skip to content

OneideLuizSchneider/kubectl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

43 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

kubectl

A lightweight Docker image bundling both kubectl and helm CLIs for Kubernetes cluster management, CI/CD automation, and scripting.

Dockerhub Link


🧰 Features

  • 🛠️ Includes:
  • 🧬 Multi-architecture support for linux/amd64 and linux/arm64
  • 📦 Minimal and portable CLI environment
  • 🚀 Ideal for:
    • CI/CD pipelines (GitHub Actions, GitLab CI, Jenkins, etc.)
    • Infrastructure automation
    • Local development without installing kubectl or helm

📝 Usage

🔍 kubectl example:

docker run --rm \
  -v ~/.kube:/root/.kube:ro \
  oneidels/kubectl \
  kubectl get pods --all-namespaces

📦 helm example:

docker run --rm \
  -v ~/.kube:/root/.kube:ro \
  -v $(pwd)/charts:/charts \
  oneidels/kubectl \
  helm install my-release /charts/my-app

⏰ Kubernetes CronJob example

Here’s a simple example of a CronJob that runs the oneidels/kubectl image to execute a Kubernetes command on a schedule:

apiVersion: batch/v1
kind: CronJob
metadata:
  name: example-kubectl-cronjob
spec:
  schedule: "0 3 * * *"  # Runs daily at 3 AM
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: kubectl
            image: oneidels/kubectl
            command:
              - /bin/sh
              - -c
              - kubectl get pods --all-namespaces
            volumeMounts:
            - name: kubeconfig
              mountPath: /root/.kube
              readOnly: true
          restartPolicy: OnFailure
          volumes:
          - name: kubeconfig
            secret:
              secretName: my-kubeconfig-secret

Note:
The example assumes you have a Kubernetes Secret named my-kubeconfig-secret containing your kubeconfig file. Adjust as needed for your environment.


📂 Volumes

  • Mount your local ~/.kube config to /root/.kube inside the container for access to clusters.
  • Mount Helm charts or other resources as needed for your use case.

📌 Notes

  • Built for quick, secure use in automation.
  • Tags follow common Kubernetes/Helm versioning.

📣 Contributing

Feel free to open issues or submit PRs to help improve this image. Feature requests welcome!


🔗 Resources


🏗️ Continuous Integration

GitHub Actions CI builds and publishes on these events:

  • Push to main: builds immediately and tags the image as oneidels/kubectl:latest, then runs smoke tests.
  • Nightly cron (00:00 UTC): fetches the stable Kubernetes release, tags the image as oneidels/kubectl:<k8s-version> and latest, then runs smoke tests.
  • Manual dispatch: run the workflow interactively from the GitHub Actions tab.

The workflow is in .github/workflows/docker-publish.yml. To enable Docker Hub pushes, set these repository secrets:

  • DOCKERHUB_USERNAME – your Docker Hub username
  • DOCKERHUB_TOKEN – Docker Hub access token or password

About

Kubectl and Helm CLI in one Docker image for Kubernetes management and automation.

Resources

License

Stars

1 star

Watchers

1 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors