Monday, February 11, 2019

How To Add OKE Worker Nodes via OCI API


  We have Kubernetes cluster running in OKE (Oracle Kubernetes Engine).  We would like to dig deeper to use OCI API to manager the node pool of our K8S cluster. ie we can add a new worker node into our new private subnet. With OCI API, we can have more flexibility to handle worker nodes in the cluster.  In this example, we plan to use curl and raw REST API calls to do that.  Later oci-cli or SDK would support such functions


  • First to install oci-curl .  It is a Bash Shell script. Please refer OCI Doc
  • Configure the oci-curl to use correct tenancyId , authUserId , keyFingerprint, privateKeyPath. More details Please refer OCI Credential Doc and  OCI API  details
  • Test oci-curl . If you can get result like below , it means it works 
# .   ./
# oci-curl GET "/20180222/clusterOptions/all"
  "kubernetesVersions": [
  • Prepare oke-nodepool.json The example of json file is like
  "compartmentId": "INSERT_YOUR_COMPARTMENT_ID",
  "clusterId": "INSERT_YOUR_CLUSTER_ID",
  "kubernetesVersion": "INSERT_YOUR_K8S_VERSION",
  "nodeShape": "INSERT_YOUR_SHAPE_NAME",
  "nodeMetadata": {
  "initialNodeLabels": [
      "key": "",
  "quantityPerSubnet": INSERT_YOUR_QTY_PER_SUBNET,
  "subnetIds": [
  • Create a node pool 
oci-curl POST ./oke-nodepool.json "/20180222/nodePools"
  • Go to the OCI ashburn console , a new nodepool would be created in OKE according to json file.

No comments: