GithubHelp home page GithubHelp logo

ysicing / cr Goto Github PK

View Code? Open in Web Editor NEW
0.0 3.0 0.0 110 KB

k8s免密拉取镜像组件

Dockerfile 3.02% Makefile 16.55% Go 77.68% Shell 2.76%
tcr acr gcr k8s dockerconfig pullimagesecrets kube kubernetes

cr's Introduction

免密拉取镜像

Usage

apiVersion: tools.51talk.me/v1beta1
kind: CR
metadata:
  name: cr-sample
spec:
  domain: root:pass:hub.baidu.com
  # sa可选, 默认default
  # sa: default
  # watchns可选,默认all
  # watchns: all

Install

kubectl apply -f https://raw.githubusercontent.com/ysicing/cr/master/hack/deploy/crd.yaml
kubectl apply -f https://raw.githubusercontent.com/ysicing/cr/master/hack/deploy/cr.yaml

Dev

参考 example/client/main.go

package main

import (
	"context"
	clientset "github.com/ysicing/cr/pkg/client/clientset/versioned"
	corev1 "k8s.io/api/core/v1"
	"k8s.io/apimachinery/pkg/api/errors"
	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
	"k8s.io/client-go/tools/clientcmd"
	"k8s.io/client-go/util/homedir"
	"k8s.io/klog/v2"
	"os"
	"path/filepath"
)

func init() {
	klog.InitFlags(nil)
}

func main() {
	// Create client
	var kubeconfig string
	kubeconfig, ok := os.LookupEnv("KUBECONFIG")
	if !ok {
		kubeconfig = filepath.Join(homedir.HomeDir(), ".kube", "config")
	}

	config, err := clientcmd.BuildConfigFromFlags("", kubeconfig)
	if err != nil {
		panic(err)
	}
	client, err := clientset.NewForConfig(config)
	if err != nil {
		panic(err)
	}
	crs, err := client.ToolsV1beta1().CRs(corev1.NamespaceAll).List(context.Background(), metav1.ListOptions{})
	if err != nil {
		if !errors.IsNotFound(err) {
			panic(err)
		}
	}
	for _, cr := range crs.Items {
		klog.Infof("ns %v, cr %v", cr.Namespace, cr.Name)
	}
}

cr's People

Contributors

ysicing avatar

Watchers

 avatar  avatar  avatar

cr's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.