hobby-kube / provisioning

Kubernetes cluster provisioning using Terraform.
https://hobby-kube.dev/guide
MIT License
312 stars 112 forks source link

Fix deprecated null_data_source #74

Open ryanzzff opened 3 years ago

ryanzzff commented 3 years ago

We can use locals instead of null_data_source.

│ Warning: Deprecated Resource
│ 
│   with module.etcd.data.null_data_source.endpoints,
│   on service/etcd/main.tf line 83, in data "null_data_source" "endpoints":
│   83: data "null_data_source" "endpoints" {
│ 
│ The null_data_source was historically used to construct intermediate values to re-use elsewhere in configuration, the same can now be achieved using locals
╵
pstadler commented 3 years ago

is this still working correctly now that there's no depends_on in place for the output variable?

ryanzzff commented 3 years ago

Sorry, I'm new to terraform and k8s, so I'm not sure if it is working "correctly", but I "think" it is ;)

command to get the ClusterConfig:

kubectl get cm kubeadm-config  -n kube-system -o yaml

output:

apiVersion: v1
data:
  ClusterConfiguration: |
    apiServer:
      certSANs:
      - <I_guess_I_should_hide_this>
      extraArgs:
        authorization-mode: Node,RBAC
      timeoutForControlPlane: 4m0s
    apiVersion: kubeadm.k8s.io/v1beta3
    certificatesDir: /etc/kubernetes/pki
    clusterName: kubernetes
    controllerManager: {}
    dns: {}
    etcd:
      external:
        caFile: ""
        certFile: ""
        endpoints:
        - http://10.0.1.1:2379
        - http://10.0.1.2:2379
        - http://10.0.1.3:2379
        keyFile: ""
    imageRepository: k8s.gcr.io
    kind: ClusterConfiguration
    kubernetesVersion: v1.22.2
    networking:
      dnsDomain: cluster.local
      serviceSubnet: 10.96.0.0/12
    scheduler: {}
kind: ConfigMap
metadata:
  creationTimestamp: "2021-09-19T16:01:04Z"
  managedFields:
  - apiVersion: v1
    fieldsType: FieldsV1
    fieldsV1:
      f:data:
        .: {}
        f:ClusterConfiguration: {}
    manager: kubeadm
    operation: Update
    time: "2021-09-19T16:01:04Z"
  name: kubeadm-config
  namespace: kube-system
  resourceVersion: "214"
  uid: 51ebd3b8-eb73-4787-9f53-4ede7318571b