一点小知识


eks中启用secret加密

eks可以启用为集群中加密的功能,这个功能能够确保 合规性 ,同时不需要用户介入操作

使用方法很简单,用户有 create grant的权限就能够为eks集群启用
启用过后可以看到一个creategrant的cloudtrail,这时候再用命令创建secret就能够实现自动加密
这里的坑是说不能删除这个key 同时不能手动revoke这个grant 否则即便加回来也不能正常使用了, 这里怀疑跟信封加密或者主密钥在eks的缓存相关,未验证。

删了grant报错如下
 k create secret generic --from-literal i=b testi
error: failed to create secret Internal error occurred: rpc error: code = DeadlineExceeded desc = latest balancer error: connection error: desc = "transport: Error while dialing di
al unix /var/run/kmsplugin/socket.sock: connect: no such file or directory"
[ec2-user@ip-10-0-0-34 ~]$ k create secret generic --from-literal i=b testi
error: failed to create secret Internal error occurred: rpc error: code = DeadlineExceeded desc = latest balancer error: connection error: desc = "transport: Error while dialing di
al unix /var/run/kmsplugin/socket.sock: connect: no such file or directory"
[ec2-user@ip-10-0-0-34 ~]$ k create secret generic --from-literal i=b testi
error: failed to create secret Internal error occurred: rpc error: code = DeadlineExceeded desc = latest balancer error: connection error: desc = "transport: Error while dialing di
al unix /var/run/kmsplugin/socket.sock: connect: no such file or directory"
[ec2-user@ip-10-0-0-34 ~]$ k get secrets testh -o yaml
apiVersion: v1
data:
  h: Yg==
kind: Secret
metadata:
  creationTimestamp: "2023-05-06T10:06:50Z"
  name: testh
  namespace: default
  resourceVersion: "82014"
  uid: 8ce8f4e0-c266-4ae7-b42b-27e24821415e
type: Opaque

把那个grant手动加回来报错如下

[ec2-user@ip-10-0-0-34 ~]$ k create secret generic --from-literal i=b testi
error: failed to create secret Internal error occurred: rpc error: code = Unknown desc = failed to encrypt AccessDeniedException:
        status code: 400, request id: 2221568f-8f6e-44ce-ac5f-fcd34a571548
[ec2-user@ip-10-0-0-34 ~]$ client_loop: send disconnect: Connection reset

题外话 eks中的crt解密命令

echo -n "LS0tLS1CRUdJTiBDRVJUSUZJQ0FURS0tLS0tCk1JSUMvakNDQWVhZ0F3SUJBZ0lCQURB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NVkM5UGtvK1dkWEJ0dS9jRHFMTUF6WjlFSWhCM25RMnNhd0ZjbFYKcDUwOFlPWU0vNU80QjdDVUZJYzExK0FtdmJiTVNDWXBDMTJDNzlLOEgvVU9KY1pKS1UxUGRLNVllZUdqTUp0RQpFM1c5cWZHZ01NeUJFS0QzcCt3MEpuSGRNM0pMUXArR1M5bzBQWFd3czFUZlIycjAxek81MjdVYlE5a1hweGt5CjFSZ1BBU3p5VjFTMmQvd0pxeldCUi9mMERUdWZDSTZYSmN2QlRkNGFJZzJUTm9LUUUvWlI5U2prV2IrMFFSSVAKdVRVPQotLS0tLUVORCBDRVJUSUZJQ0FURS0tLS0tCg=="|base64 -d | openssl x509  -text -noout

文章作者: Felix Li
版权声明: 本博客所有文章除特別声明外,均采用 CC BY 4.0 许可协议。转载请注明来源 Felix Li !
  目录