【发布时间】:2021-03-12 09:31:44
【问题描述】:
我正在开发基于 ansible 的 kubernetes 算子。 我正在尝试从 let's encrypt 发布的 kubernetes 机密中读取 tls.key 和 tls.crt,并通过 ansible 任务将其转换为 Windows IIS 证书。
apiVersion: win-cert.test.net/v1alpha1
kind: WindowsCert
metadata:
name: windowscert-sample
spec:
pfx_file: test
pfx_state: present
pfx_crt:
valueFrom:
secretKeyRef:
name: cert-manager
key: tls.crt
pfx_key:
valueFrom:
secretKeyRef:
name: cert-manager
key: tls.key
pfx_ca: ''
pfx_output_file: ''
我的自定义资源定义如下所示:
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
name: windowscerts.win-cert.tests.net
spec:
group: win-cert.test.net
names:
kind: WindowsCert
listKind: WindowsCertList
plural: windowscerts
singular: windowscert
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: WindowsCert is the Schema for the windowscerts API
properties:
apiVersion:
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
spec:
description: Spec defines the desired state of WindowsCert
type: object
x-kubernetes-preserve-unknown-fields: true
properties:
cronSpec:
description: 'Specify under crontab format interval to run windows cert ansible playbook'
type: string
pattern: '^(\d+|\*)(/\d+)?(\s+(\d+|\*)(/\d+)?){4}$'
default: "5 0 * * *"
pfx_file:
type: string
pfx_state:
type: string
pfx_crt:
type: string
pfx_ca:
type: string
pfx_key:
type: string
pfx_output_file:
type: string
status:
description: Status defines the observed state of WindowsCert
type: object
x-kubernetes-preserve-unknown-fields: true
type: object
served: true
storage: true
subresources:
status: {}
如何使用 secret 中的值填充此字段 pfx_key 和 cert 字段?
【问题讨论】:
-
到目前为止,您的控制器有什么代码?你使用的是 kubebuilder 或 operator-sdk 之类的框架吗?
-
@DavidMaze 我正在使用 operator-sdk
-
请尝试添加更多关于您尝试过的内容和遇到的问题的信息。我还建议尝试使用标准 ansible 解决这个问题,而不是使用操作员框架。这个问题表明对 kubernetes 缺乏整体了解——添加操作符只会让事情变得更加复杂。
-
有什么解决方案吗?
标签: kubernetes openshift