我最近应用了这个 CRD 文件
https://raw.githubusercontent.com/jetstack/cert-manager/release-0.11/deploy/manifests/00-crds.yaml
Run Code Online (Sandbox Code Playgroud)
随着kubectl apply安装此:https://hub.helm.sh/charts/jetstack/cert-manager
我想我成功地应用了它:
xetra11@x11-work configuration]$ kubectl apply -f ./helm-charts/certificates/00-crds.yaml --validate=false
customresourcedefinition.apiextensions.k8s.io/challenges.acme.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/orders.acme.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/certificaterequests.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/certificates.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/clusterissuers.cert-manager.io created
customresourcedefinition.apiextensions.k8s.io/issuers.cert-manager.io created
Run Code Online (Sandbox Code Playgroud)
但是现在我想“看看”我刚刚在这里应用的内容。我不知道如何列出这些定义,或者例如删除它们,如果我认为它们会以某种方式搞砸我的集群。
我在这里找不到任何信息:https : //kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/#preparing-to-install-a-custom-resource
我有一个 helm 图表 A,它依赖于第三方子图表 B。图表 B 定义了图表 A 使用的一些 CRD。但是,当我安装图表 A(因此也是 B)时,我收到一条错误消息,指出 CRD 是未能识别。看来 CR 是在 CRD 之前存储的。
有关CRD的 Helm 文档 描述了两种处理此订单的方法,要么将 CRD 放在名为 crds 的文件夹中,要么使用两个单独的图表并一个接一个地安装它们。
我的问题如下:
(您不必回答所有问题,只要回答其中任何一个问题即可)
在运行脚本之前仅使用kubectl命令行检查自定义资源定义是否存在的最佳方法是什么?
我们有一个包含了NATS集群定义YAML文件ServiceAccount,Role,ClusterRoleBinding和Deployment。中使用的映像Deployment创建crd,第二个脚本使用它crd来部署一组pods. 目前,我们的 CI 管道需要多次运行第二个脚本,只有crd在完全创建后才能成功完成。我尝试使用kubectl wait但无法弄清楚适用于完成crd.
下面是我最近的尝试,尽管完全错误,但这说明了我们想要的一般顺序。
kubectl wait --for=condition=complete kubectl apply -f 1.nats-cluster-operator.yaml kubectl apply -f 2.nats-cluster.yaml
wait kubernetes azure-devops kubectl kubernetes-custom-resources
我已在 Kubernetes 集群中创建了自定义资源定义 (CRD) 和自定义资源 (CR),但在 CR 控制器中,如何创建附加到自定义资源的Kubernetes 事件?我希望通过事件,用户在运行时能够看到与 CR 相关的重要消息kubectl describe <cr>。
我刚刚开始使用 kubebuilder 和 Golang 使用自定义资源扩展我们的 Kubernetes 集群。我很想根据实际调用它的事件在协调器功能中做不同的事情。
资源创建了吗?更新了吗?被删了吗?
这些事件中的每一个都会触发控制器,但是,我似乎无法找到查看哪些事件实际发生的可能性。我可以通过编写这样的协调器来解决这个问题:
func (r *ServiceDescriptorReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctrl.Result, error) {
service := &batchv1.ServiceDescriptor{}
if err := r.Get(context.TODO(), req.NamespacedName, service); err != nil && errors.IsNotFound(err) {
fmt.Println("Resource was not found -> must have been deleted")
else {
fmt.Println("No errors found -> Resource must have been created or updated")
}
}
Run Code Online (Sandbox Code Playgroud)
然而,这感觉奇怪地含蓄而且有点老套。
是否有一种干净的(可能是本机的)方法来获取协调器调用的事件类型?
我正在尝试创建一个 kubernetes 自定义资源定义(名为Block),但不断遇到以下错误:
Failed to list *v1alpha1.Block: the server could
not find the requested resource (get
blocks.kubechain.com).
Run Code Online (Sandbox Code Playgroud)
此问题是由于调用List此 CRD 的控制器而引发的:
indexer, controller := cache.NewIndexerInformer(
&cache.ListWatch{
ListFunc: func(lo metav1.ListOptions) (result k8sruntime.Object, err error) {
return clientSet.Block(ns).List(lo)
},
WatchFunc: func(lo metav1.ListOptions) (watch.Interface, error) {
return clientSet.Block(ns).Watch(lo)
},
},
&v1alpha1.Block{},
1*time.Minute,
cache.ResourceEventHandlerFuncs{},
cache.Indexers{},
)
Run Code Online (Sandbox Code Playgroud)
对于某些上下文,这里是register.go我将上述资源注册到方案构建器的文件:
// GroupName is the api prefix.
const GroupName = "kubechain.com"
// GroupVersion is the version of the api.
const GroupVersion = "v1alpha1" …Run Code Online (Sandbox Code Playgroud) 我在集群中创建了自定义资源定义(CRD)及其控制器,现在可以创建自定义资源,但是如何验证对CR的更新请求?例如,仅某些字段可以更新。
我有一些 CRD,每个 CRD 都应该Container.Spec在整个集群中进行 edit 。如 ENV、标签等...
如果资源由多个控制器管理,可以吗?
这种方法可能存在哪些缺陷?
kubernetes kubernetes-custom-resources kubernetes-operator operator-sdk
我最近开始构建Kubernetes Operator。我正在使用Fabric8 Java Kubernetes 客户端,但我认为我的问题更普遍,也适用于其他编程语言和库。
当阅读解释运算符模式的博客文章、文档或教科书时,我发现设计运算符似乎有两种选择:
但是,我没有找到任何源讨论在哪种情况下应该使用哪个选项。有没有最佳实践?
fabric8 kubernetes kubernetes-custom-resources kubernetes-operator
我正在使用 Operator-sdk 构建一个基于 GO 的操作员来管理名为“Module拥有部署”的自定义资源。我的_types.go看起来像这样:
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:subresource:scale:specpath=.spec.workerSettings.replicas,statuspath=.status.replicas,selectorpath=.status.selector
//+kubebuilder:printcolumn:name="Replicas",type="integer",JSONPath=".spec.workerSettings.replicas",description="The number of pods for this Module"
//+kubebuilder:printcolumn:name="Ready",type="integer",JSONPath=".status.readyReplicas",description="The number of ready pods for this Module"
//+kubebuilder:resource:shortName=mod;mods
// Module is the Schema for the Module API
type Module struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Spec ModuleSpec `json:"spec,omitempty"`
Status ModuleStatus `json:"status,omitempty"`
}
// ModuleStatus defines the observed state of Module
type ModuleStatus struct {
Replicas int32 `json:"replicas"`
ReadyReplicas int32 `json:"readyReplicas"`
Selector string `json:"selector"`
Conditions []metav1.Condition `json:"conditions"`
}
Run Code Online (Sandbox Code Playgroud)
在协调中,我尝试设置ReadyReplicasCR …
kubernetes ×10
kubernetes-custom-resources ×10
go ×3
operator-sdk ×2
azure-devops ×1
fabric8 ×1
kubebuilder ×1
kubectl ×1
wait ×1