karmada-io / karmada

Open, Multi-Cloud, Multi-Cluster Kubernetes Orchestration
https://karmada.io
Apache License 2.0
4.47k stars 883 forks source link

[operator] Implement the external etcd #3860

Open liangyuanpeng opened 1 year ago

liangyuanpeng commented 1 year ago

What would you like to be added:

Implement the external etcd for operator, now, it just have api and have not implement.

And i want to change the API:

https://github.com/karmada-io/karmada/blob/ee3fa49ac041f2fc849690b1cadbf27911b96b58/operator/pkg/apis/operator/v1alpha1/type.go#L201-L209

This there field is the type of []byte and it's not working from yaml.

  components:
    etcd:
      external:
        endpoints: https://172.18.0.2:31079
        caData: "asd"
        certData: "213a"
        keyData: "asd"
...

Just got the error:

The Karmada "karmada-demo" is invalid: 
* spec.components.etcd.external.caData: Invalid value: "asd": spec.components.etcd.external.caData in body must be of type byte: "asd"
* spec.components.etcd.external.endpoints: Invalid value: "string": spec.components.etcd.external.endpoints in body must be of type array: "string"
* spec.components.etcd.external.keyData: Invalid value: "asd": spec.components.etcd.external.keyData in body must be of type byte: "asd"

I propose to fill ca tls with secret, it would be like that:

  components:
    etcd:
      external:
        endpoints: https://172.18.0.2:31079
    cASecret:
          name: {secretName}
          key: {secretKey}
    certSecret:
          name: {secretName}
          key: {secretKey}
    keySecret:
          name: {secretName}
          key: {secretKey}

This can achieve the effect of reusing.

Why is this needed:

Use external etcd with operator, now, i use extraArgs for it.

...
    karmadaAPIServer:
      imageRepository: registry.k8s.io/kube-apiserver
      imageTag: v1.25.4
      replicas: 1
      serviceType: NodePort
      serviceSubnet: 10.96.0.0/12
      extraArgs: 
        etcd-servers: http://172.18.0.2:31079
        etcd-prefix: /karmada
    karmadaAggregatedAPIServer:
      imageRepository: docker.io/karmada/karmada-aggregated-apiserver
      imageTag: v1.6.0
      replicas: 1
      extraArgs:
        etcd-servers: http://172.18.0.2:31079
        etcd-prefix: /karmada
...

/cc @RainbowMango @calvin0327 for confirm that, Thanks.

/assign

tedli commented 1 year ago

3897