|
| 1 | +#+title: OCI CAPI cluster |
| 2 | + |
| 3 | +Bring up Kubernetes locally |
| 4 | + |
| 5 | +#+begin_src bash |
| 6 | +kind create cluster |
| 7 | +#+end_src |
| 8 | + |
| 9 | +#+begin_src bash :tangle .envrc |
| 10 | +[ ! -f priv.env ] || . priv.env |
| 11 | +# export OCI_TENANCY_ID= |
| 12 | +# export OCI_USER_ID= |
| 13 | +# export OCI_CREDENTIALS_FINGERPRINT= |
| 14 | +# export OCI_CREDENTIALS_KEY_B64= # $(base64 < path/to/a/key.pem | tr -d '\n') |
| 15 | +export OCI_REGION=us-sanjose-1 |
| 16 | + |
| 17 | +export OCI_TENANCY_ID_B64="$(echo -n "$OCI_TENANCY_ID" | base64 | tr -d '\n')" |
| 18 | +export OCI_CREDENTIALS_FINGERPRINT_B64="$(echo -n "$OCI_CREDENTIALS_FINGERPRINT" | base64 | tr -d '\n')" |
| 19 | +export OCI_USER_ID_B64="$(echo -n "$OCI_USER_ID" | base64 | tr -d '\n')" |
| 20 | +export OCI_REGION_B64="$(echo -n "$OCI_REGION" | base64 | tr -d '\n')" |
| 21 | + |
| 22 | +# if bootstraping from inside OCI |
| 23 | +export USE_INSTANCE_PRINCIPAL="false" |
| 24 | +export USE_INSTANCE_PRINCIPAL_B64="$(echo -n "$USE_INSTANCE_PRINCIPAL" | base64 | tr -d '\n')" |
| 25 | +#+end_src |
| 26 | + |
| 27 | +allow env from .envrc |
| 28 | + |
| 29 | +#+begin_src bash |
| 30 | +direnv allow |
| 31 | +#+end_src |
| 32 | + |
| 33 | +bootstrap capi with oci |
| 34 | + |
| 35 | +#+begin_src bash |
| 36 | +clusterctl init -b talos:v0.6.5 -c talos:v0.5.6 --infrastructure oci:v0.16.0 |
| 37 | +#+end_src |
| 38 | + |
| 39 | +create a namespace |
| 40 | + |
| 41 | +#+begin_src bash |
| 42 | +kubectl create ns sharingio |
| 43 | +#+end_src |
| 44 | + |
| 45 | +#+RESULTS: |
| 46 | +#+begin_example |
| 47 | +namespace/sharingio created |
| 48 | +#+end_example |
| 49 | + |
| 50 | +Generate a cluster config |
| 51 | + |
| 52 | +#+begin_src bash :tangle .envrc |
| 53 | +# export OCI_COMPARTMENT_ID= |
| 54 | +# export OCI_IMAGE_ID=ocid1.image.oc1.us-sanjose-1.aaaaaaaazpwpyk7kh6mbu2g6yihups2zf5uwt7moehbafxsu4idaew6nggxq # NOTE Oracle 8 |
| 55 | +export OCI_IMAGE_ID=ocid1.image.oc1.us-sanjose-1.aaaaaaaaqemyxu4dnhuapt6dfzuhq6rp5h3f7ld3yqh3crwiu5qtzlk6woma |
| 56 | +export OCI_CONTROL_PLANE_MACHINE_TYPE=VM.Standard.A1.Flex |
| 57 | +export OCI_CONTROL_PLANE_MACHINE_TYPE_OCPUS=4 |
| 58 | +export OCI_NODE_MACHINE_TYPE=VM.Standard.A1.Flex |
| 59 | +export OCI_NODE_MACHINE_TYPE_OCPUS=8 |
| 60 | +export OCI_SSH_KEY= |
| 61 | +export OCI_CONTROL_PLANE_PV_TRANSIT_ENCRYPTION=true |
| 62 | +export OCI_NODE_PV_TRANSIT_ENCRYPTION=true |
| 63 | + |
| 64 | +export TALOS_INSTALL_IMAGE=factory.talos.dev/installer/d01e4eb407f9a242831748cab07de55550fdcfe8be65ce4defd258a93d94562f:v1.7.6 |
| 65 | +export CLUSTER_NAME=sharingio |
| 66 | +export CONTROL_PLANE_MACHINE_COUNT=3 |
| 67 | +export KUBERNETES_VERSION=v1.30.1 |
| 68 | +export NAMESPACE=sharingio |
| 69 | +export POD_CIDR=192.168.0.0/16 |
| 70 | +export SERVICE_CIDR=10.128.0.0/12 |
| 71 | +export NODE_MACHINE_COUNT=6 |
| 72 | + |
| 73 | +#+end_src |
| 74 | + |
| 75 | +generate a cluster config |
| 76 | + |
| 77 | +#+begin_src bash |
| 78 | +clusterctl -n sharingio generate cluster "$CLUSTER_NAME" --from ./cluster-template.yaml --write-to ./cluster.yaml |
| 79 | +#+end_src |
| 80 | + |
| 81 | +#+RESULTS: |
| 82 | +#+begin_example |
| 83 | +#+end_example |
| 84 | + |
| 85 | +apply the cluster |
| 86 | + |
| 87 | +#+begin_src bash |
| 88 | +kubectl -n sharingio apply -f ./cluster.yaml |
| 89 | +#+end_src |
| 90 | + |
| 91 | +#+RESULTS: |
| 92 | +#+begin_example |
| 93 | +cluster.cluster.x-k8s.io/sharingio created |
| 94 | +ocicluster.infrastructure.cluster.x-k8s.io/sharingio created |
| 95 | +taloscontrolplane.controlplane.cluster.x-k8s.io/sharingio-control-plane created |
| 96 | +ocimachinetemplate.infrastructure.cluster.x-k8s.io/sharingio-control-plane created |
| 97 | +ocimachinetemplate.infrastructure.cluster.x-k8s.io/sharingio-md-0 created |
| 98 | +talosconfigtemplate.bootstrap.cluster.x-k8s.io/sharingio-md-0 created |
| 99 | +machinedeployment.cluster.x-k8s.io/sharingio-md-0 created |
| 100 | +#+end_example |
| 101 | + |
| 102 | +view the world |
| 103 | + |
| 104 | +#+begin_src shell |
| 105 | +kubectl -n sharingio get $(kubectl -n sharingio api-resources | grep x-k8s | awk '{print $1}' | tr '\n' ',' | sed 's/,$//g') |
| 106 | +#+end_src |
| 107 | + |
| 108 | +#+RESULTS: |
| 109 | +#+begin_example |
| 110 | +NAME AGE |
| 111 | +talosconfig.bootstrap.cluster.x-k8s.io/sharingio-md-0-gjmhg-2zps4 50s |
| 112 | +talosconfig.bootstrap.cluster.x-k8s.io/sharingio-md-0-gjmhg-8ts94 50s |
| 113 | +talosconfig.bootstrap.cluster.x-k8s.io/sharingio-md-0-gjmhg-frc97 50s |
| 114 | +talosconfig.bootstrap.cluster.x-k8s.io/sharingio-md-0-gjmhg-j77b6 50s |
| 115 | +talosconfig.bootstrap.cluster.x-k8s.io/sharingio-md-0-gjmhg-mbcs8 50s |
| 116 | +talosconfig.bootstrap.cluster.x-k8s.io/sharingio-md-0-gjmhg-w847p 50s |
| 117 | + |
| 118 | +NAME AGE |
| 119 | +talosconfigtemplate.bootstrap.cluster.x-k8s.io/sharingio-md-0 85s |
| 120 | + |
| 121 | +NAME CLUSTERCLASS PHASE AGE VERSION |
| 122 | +cluster.cluster.x-k8s.io/sharingio Provisioned 72s |
| 123 | + |
| 124 | +NAME CLUSTER REPLICAS READY UPDATED UNAVAILABLE PHASE AGE VERSION |
| 125 | +machinedeployment.cluster.x-k8s.io/sharingio-md-0 sharingio 6 6 6 ScalingUp 71s v1.30.1 |
| 126 | + |
| 127 | +NAME CLUSTER NODENAME PROVIDERID PHASE AGE VERSION |
| 128 | +machine.cluster.x-k8s.io/sharingio-md-0-gjmhg-2zps4 sharingio Pending 50s v1.30.1 |
| 129 | +machine.cluster.x-k8s.io/sharingio-md-0-gjmhg-8ts94 sharingio Pending 50s v1.30.1 |
| 130 | +machine.cluster.x-k8s.io/sharingio-md-0-gjmhg-frc97 sharingio Pending 50s v1.30.1 |
| 131 | +machine.cluster.x-k8s.io/sharingio-md-0-gjmhg-j77b6 sharingio Pending 50s v1.30.1 |
| 132 | +machine.cluster.x-k8s.io/sharingio-md-0-gjmhg-mbcs8 sharingio Pending 50s v1.30.1 |
| 133 | +machine.cluster.x-k8s.io/sharingio-md-0-gjmhg-w847p sharingio Pending 50s v1.30.1 |
| 134 | + |
| 135 | +NAME CLUSTER REPLICAS READY AVAILABLE AGE VERSION |
| 136 | +machineset.cluster.x-k8s.io/sharingio-md-0-gjmhg sharingio 6 50s v1.30.1 |
| 137 | + |
| 138 | +NAME READY INITIALIZED REPLICAS READY REPLICAS UNAVAILABLE REPLICAS |
| 139 | +taloscontrolplane.controlplane.cluster.x-k8s.io/sharingio-control-plane |
| 140 | + |
| 141 | +NAME AGE |
| 142 | +ocicluster.infrastructure.cluster.x-k8s.io/sharingio 56s |
| 143 | + |
| 144 | +NAME AGE |
| 145 | +ocimachine.infrastructure.cluster.x-k8s.io/sharingio-md-0-gjmhg-2zps4 50s |
| 146 | +ocimachine.infrastructure.cluster.x-k8s.io/sharingio-md-0-gjmhg-8ts94 50s |
| 147 | +ocimachine.infrastructure.cluster.x-k8s.io/sharingio-md-0-gjmhg-frc97 50s |
| 148 | +ocimachine.infrastructure.cluster.x-k8s.io/sharingio-md-0-gjmhg-j77b6 50s |
| 149 | +ocimachine.infrastructure.cluster.x-k8s.io/sharingio-md-0-gjmhg-mbcs8 50s |
| 150 | +ocimachine.infrastructure.cluster.x-k8s.io/sharingio-md-0-gjmhg-w847p 50s |
| 151 | + |
| 152 | +NAME AGE |
| 153 | +ocimachinetemplate.infrastructure.cluster.x-k8s.io/sharingio-control-plane 56s |
| 154 | +ocimachinetemplate.infrastructure.cluster.x-k8s.io/sharingio-md-0 56s |
| 155 | +#+end_example |
0 commit comments