oracle-cne / ocne

The Oracle Cloud Native Environment CLI
Universal Permissive License v1.0
1 stars 0 forks source link

Added OCNE_DEFAULTS environment variable to change the path of the default configuration #111

Closed dkrasins closed 3 days ago

dkrasins commented 3 days ago

Allows users to override the location of the default configuration file.

Example

#
#   Set an alternate default file that has no proxy configuration
#
$ cat ~/.ocne/defaults-noproxy.yaml
extraIgnitionInline: |
  variant: fcos
  version: 1.5.0
  passwd:
    users:
      - name: dkrasins
        groups:
          - wheel
        ssh_authorized_keys:
          - ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDAfNhm5APW2kctfj+O8IRInlFivqoQMvMQ9CCNMq5IavW+CKTJUQ74pn8YkAmagM44zXPpwDoFiE+Wmk7fncigMu/x6T1qDLlz0P5XCXU1LQD35MOjtzQPyIRngaDbJ3f4H34w/WzyFVAH4wOPCiTa3eHRWU9ZLBK5MooDp1paC91NDUU4iLmRIVgBPbI7XPziRRvKQpUo9MPmXSjvOY/bvwAFZZB0uePR6RQBofVABisUJEE1Coo3EZmreekoreftUH6Xm+JI016sXMkQydfHsHztEL2C4zYUOfZmya0ThWkYSelUyZmOJU+3R3CQ56F04YGdqIQPA7WLGH0Q/IXzIGE2cNVxsceFraVLCuRTnzHoh4Hg6BrfVWWAm2siGNZP/6hldA3TIpyHMDKE6wJ3T/iONP1eI6ojgz6rnRUQzgxzjEGCpSuoFWaPlweYKksldIuflKijC3jGAbmqFNe/6UMVmGk7nRu/IE2K7XO/bgSTOCxf+KPUBCfATGiK3y0= root@dkrasins-dev-ol9

$ OCNE_DEFAULTS=$(realpath ~/.ocne/defaults-noproxy.yaml) ./out/linux_amd64/ocne cluster start -C otherdefaults --auto-start-ui=false
INFO[2024-10-18T15:48:08Z] Creating new Kubernetes cluster with version 1.30 named otherdefaults 
INFO[2024-10-18T15:48:53Z] Waiting for the Kubernetes cluster to be ready: ok 
...
Run the following command to create an authentication token to access the UI:
    kubectl create token ui -n ocne-system 
[opc@dkrasins-dev-ol9 ocne]$ ocne cluster show -C otherdefaults -f 'config.proxy'
httpsProxy: ""
httpProxy: ""
noProxy: ""

$ ocne cluster delete -C otherdefaults
INFO[2024-10-18T15:49:20Z] Deleting volume otherdefaults-control-plane-1-init.ign 
INFO[2024-10-18T15:49:20Z] Deleting volume otherdefaults-control-plane-1.qcow2 
INFO[2024-10-18T15:49:20Z] Deleting file /home/opc/.kube/kubeconfig.otherdefaults.local 
INFO[2024-10-18T15:49:20Z] Deleting file /home/opc/.kube/kubeconfig.otherdefaults.vm 

#
#  Set a default configuration file that has a proxy set
#
$ cat ~/.ocne/defaults-fakeproxy.yaml 
proxy:
  httpsProxy: "https://fakeproxy.com:80"
  httpProxy: "https://fakeproxy.com:80"
  noProxy: "0.0.0.0/0"

$ OCNE_DEFAULTS=$(realpath ~/.ocne/defaults-fakeproxy.yaml) ./out/linux_amd64/ocne cluster start -C otherdefaults --auto-start-ui=false
INFO[2024-10-18T15:49:32Z] Creating new Kubernetes cluster with version 1.30 named otherdefaults 
INFO[2024-10-18T15:50:20Z] Waiting for the Kubernetes cluster to be ready: ok 
...
Run the following command to create an authentication token to access the UI:
    kubectl create token ui -n ocne-system 

$ ocne cluster show -C otherdefaults -f 'config.proxy'
httpsProxy: https://fakeproxy.com:80
httpProxy: https://fakeproxy.com:80
noProxy: 0.0.0.0/0