Navigation Menu |
- Comprehensive Blog on Oracle Kubernetes Engine – getting started
- Configure Network for OKE
- Create 3 Worker Node and 2 Subnets
- Create Kubernetes Cluster
- Enable Cluster access through Command line interface
- Getting onto Kubernetes Dashboard
- Running Ngnix on Load Balancer
- Pod Configuration using a YAML Deployment
Install KubeCTL
I am using Ubuntu 18.04 as my local desktop
sudo apt-get update && sudo apt-get install -y apt-transport-https curl -s https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key add - sudo touch /etc/apt/sources.list.d/kubernetes.list echo "deb http://apt.kubernetes.io/ kubernetes-xenial main" | sudo tee -a /etc/apt/sources.list.d/kubernetes.list sudo apt-get update ... sudo apt-get install -y kubectl Reading package lists... Done Building dependency tree Reading state information... Done The following packages were automatically installed and are no longer required: libboost-filesystem1.62.0 libboost-system1.62.0 libcapnp-0.6.1 libleveldb1v5 libmirclient9 libmircommon7 libmircore1 libmirprotobuf3 libqt5multimedia5 libwnck-common libwnck22 smplayer-l10n Use 'sudo apt autoremove' to remove them. The following NEW packages will be installed: kubectl 0 upgraded, 1 newly installed, 0 to remove and 361 not upgraded. Need to get 9,592 kB of archives. After this operation, 57.4 MB of additional disk space will be used. Get:1 https://packages.cloud.google.com/apt kubernetes-xenial/main amd64 kubectl amd64 1.12.0-00 [9,592 kB] Fetched 9,592 kB in 17s (570 kB/s) Selecting previously unselected package kubectl. (Reading database ... 793110 files and directories currently installed.) Preparing to unpack .../kubectl_1.12.0-00_amd64.deb ... Unpacking kubectl (1.12.0-00) ... Setting up kubectl (1.12.0-00) ... [email protected]:~$ kubectl kubectl controls the Kubernetes cluster manager.
Install CLI
Download oci-cli-2.4.33.zip from https://github.com/oracle/oci-cli/releases
unzip oci-cli-2.4.33.zip cd oci-cli/ sudo apt install python-pip ~/kube/oci-cli$ pip install oci_cli-*-py2.py3-none-any.whl [email protected]:~/kube/oci-cli$ pip install oci_cli-*-py2.py3-none-any.whl Processing ./oci_cli-2.4.33-py2.py3-none-any.whl Collecting configparser==3.5.0 (from oci-cli==2.4.33) Downloading https://files.pythonhosted.org/packages/7c/69/c2ce7e 91c89dc073eb1aa74c0621c3eefbffe8216b3f9af9d3885265c01c/configparser-3.5.0.tar.gz Collecting python-dateutil==2.7.3 (from oci-cli==2.4.33) Downloading https://files.pythonhosted.org/packages/cf/f5/af2b0 9c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/ python_dateutil-2.7.3-py2.py3-none-any.whl (211kB) 100% |████████████████████████████████| 215kB 603kB/s Collecting cryptography==2.1.3 (from oci-cli==2.4.33) Downloading https://files.pythonhosted.org/packages/ff/ac/1e88d6 6b4bfba41565cb8b3a28d9abcf8e228e5e31cd283a353b6a8bfe08/ cryptography-2.1.3-cp27-cp27mu-manylinux1_x86_64.whl (2.2MB) 100% |████████████████████████████████| 2.2MB 441kB/s Collecting six==1.11.0 (from oci-cli==2.4.33) Downloading https://files.pythonhosted.org/packages/67/4b/141a5811 04b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/ six-1.11.0-py2.py3-none-any.whl Collecting click==6.7 (from oci-cli==2.4.33) Downloading https://files.pythonhosted.org/packages/34/c1/8806f997 13ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77/ click-6.7-py2.py3-none-any.whl (71kB) 100% |████████████████████████████████| 71kB 5.3MB/s Collecting arrow==0.10.0 (from oci-cli==2.4.33) Downloading https://files.pythonhosted.org/packages/54/db/76459c4dd 3561bbe682619a5c576ff30c42e37c2e01900ed30a501957150/arrow-0.10.0.tar.gz (86kB) .... Successfully built configparser arrow retrying terminaltables pycparser Installing collected packages: ... ~/kube/oci-cli$ pip install oci-cli Collecting oci-cli Using cached https://files.pythonhosted.org/packages/66/06/ 71dca70dee3bfa82c4745f970e60c17449f905a743ba631ea6968a1ccf1c/ oci_cli-2.4.33-py2.py3-none-any.whl Collecting configparser==3.5.0 (from oci-cli) Collecting python-dateutil==2.7.3 (from oci-cli) Using cached https://files.pythonhosted.org/packages/cf/f5/ af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/ python_dateutil-2.7.3-py2.py3-none-any.whl Collecting cryptography==2.1.3 (from oci-cli) Using cached https://files.pythonhosted.org/packages/ff/ac/ 1e88d66b4bfba41565cb8b3a28d9abcf8e228e5e31cd283a353b6a8bfe08/ cryptography-2.1.3-cp27-cp27mu-manylinux1_x86_64.whl
GENERATE KEYS
for your local Ubuntu Desktop Machine make a directory ocikeys and run following commands inside it
REMEMBER the url for .PEM file we would need this file later
/home/oracle/kube/ocikeys/oci_api_key.pem
[email protected]:~/kube/ocikeys$ openssl genrsa -out oci_api_key.pem 2048 Generating RSA private key, 2048 bit long modulus ................+++ ..........................................................+++ e is 65537 (0x010001) [email protected]:~/kube/ocikeys$ openssl rsa -pubout -in oci_api_key.pem -out oci_api_key_public.pem writing RSA key [email protected]:~/kube/ocikeys$ [email protected]:~/kube/ocikeys$ ls oci_api_key.pem oci_api_key_public.pem
Now should now open .pem file in a text pad and copy paste
Click Add
Access Kubeconfig
Access Active Clusters
Click on Access KubeConfig button
if the OCI CLI Commands dont work , try the below one
[email protected]:~/kube/oci-cli$ bash -c "$(curl -L https://raw.githubusercontent.com/oracle/oci-cli/master/scripts/install/install.sh)" % Total % Received % Xferd Average Speed Time Time Time Current Dload Upload Total Spent Left Speed 100 6225 100 6225 0 0 392 0 0:00:15 0:00:15 --:--:-- 1430 Downloading Oracle Cloud Infrastructure CLI install script from https://raw.githubusercontent.com/oracle/oci-cli/5657b833bfcf16298d43fb6f0204cd66173c5ac0/scripts/install/install.py to /tmp/oci_cli_install_tmp_3dWD. ######################################################################################################################################### 100.0% Running install script. -- Verifying Python version. -- Python version 3.6.5 okay. -- Verifying native dependencies. -- Unable to verify native dependencies. dist=ubuntu, version=18.04. Continuing... ===> In what directory would you like to place the install? (leave blank to use '/home/oracle/lib/oracle-cli'): /home/oracle/kube/oracle-cli -- We will install at '/home/oracle/kube/oracle-cli'. ===> In what directory would you like to place the 'oci' executable? (leave blank to use '/home/oracle/bin'): /home/oracle/kube/bin -- The executable will be in '/home/oracle/kube/bin'. -- Downloading virtualenv package from https://github.com/pypa/virtualenv/archive/15.0.0.tar.gz. -- Downloaded virtualenv package to /tmp/tmp4stdxpko/15.0.0.tar.gz. -- Checksum of /tmp/tmp4stdxpko/15.0.0.tar.gz OK. -- Extracting '/tmp/tmp4stdxpko/15.0.0.tar.gz' to '/tmp/tmp4stdxpko'. -- Executing: ['/usr/bin/python3', 'virtualenv.py', '--python', '/usr/bin/python3', '/home/oracle/kube/oracle-cli'] Already using interpreter /usr/bin/python3 Using base prefix '/usr' New python executable in /home/oracle/kube/oracle-cli/bin/python3 Also creating executable in /home/oracle/kube/oracle-cli/bin/python Installing setuptools, pip, wheel...done. -- Executing: ['/home/oracle/kube/oracle-cli/bin/pip', 'install', '--cache-dir', '/tmp/tmp4stdxpko', 'oci_cli', '--upgrade'] Collecting oci_cli Downloading https://files.pythonhosted.org/packages/66/06/71dca70dee3bfa82c4745f970e60c17449f905a743ba631ea6968a1ccf1c/oci_cli-2.4.33-py2.py3-none-any.whl (2.1MB) 100% |████████████████████████████████| 2.1MB 6.7MB/s Collecting arrow==0.10.0 (from oci_cli) Downloading https://files.pythonhosted.org/packages/54/db/76459c4dd3561bbe682619a5c576ff30c42e37c2e01900ed30a501957150/arrow-0.10.0.tar.gz (86kB) 100% |████████████████████████████████| 92kB 19.3MB/s Collecting pytz==2016.10 (from oci_cli) Downloading https://files.pythonhosted.org/packages/f5/fa/4a9aefc206aa49a4b5e0a72f013df1f471b4714cdbe6d78f0134feeeecdb/pytz-2016.10-py2.py3-none-any.whl (483kB) 100% |████████████████████████████████| 491kB 21.9MB/s Collecting idna<2.7,>=2.5 (from oci_cli) Downloading https://files.pythonhosted.org/packages/27/cc/6dd9a3869f15c2edfab863b992838277279ce92663d334df9ecf5106f5c6/idna-2.6-py2.py3-none-any.whl (56kB) 100% |████████████████████████████████| 61kB 10.4MB/s Collecting certifi (from oci_cli) Downloading https://files.pythonhosted.org/packages/df/f7/04fee6ac349e915b82171f8e23cee63644d83663b34c539f7a09aed18f9e/certifi-2018.8.24-py2.py3-none-any.whl (147kB) 100% |████████████████████████████████| 153kB 21.0MB/s Collecting cryptography==2.1.3 (from oci_cli) Downloading https://files.pythonhosted.org/packages/91/5f/8bb6739c8312081549fcfb9653fdcc6a45eabac4d481ed120d6a9d33c2e1/cryptography-2.1.3-cp36-cp36m-manylinux1_x86_64.whl (2.2MB) 100% |████████████████████████████████| 2.2MB 7.0MB/s Collecting click==6.7 (from oci_cli) Downloading https://files.pythonhosted.org/packages/34/c1/8806f99713ddb993c5366c362b2f908f18269f8d792aff1abfd700775a77/click-6.7-py2.py3-none-any.whl (71kB) 100% |████████████████████████████████| 71kB 13.1MB/s Collecting six==1.11.0 (from oci_cli) Downloading https://files.pythonhosted.org/packages/67/4b/141a581104b1f6397bfa78ac9d43d8ad29a7ca43ea90a2d863fe3056e86a/six-1.11.0-py2.py3-none-any.whl Collecting httpsig-cffi==15.0.0 (from oci_cli) Downloading https://files.pythonhosted.org/packages/93/f5/c9a213c0f906654c933f1192148d8aded2022678ad6bce8803d3300501c6/httpsig_cffi-15.0.0-py2.py3-none-any.whl Collecting configparser==3.5.0 (from oci_cli) Downloading https://files.pythonhosted.org/packages/7c/69/c2ce7e91c89dc073eb1aa74c0621c3eefbffe8216b3f9af9d3885265c01c/configparser-3.5.0.tar.gz Collecting jmespath==0.9.3 (from oci_cli) Downloading https://files.pythonhosted.org/packages/b7/31/05c8d001f7f87f0f07289a5fc0fc3832e9a57f2dbd4d3b0fee70e0d51365/jmespath-0.9.3-py2.py3-none-any.whl Collecting oci==2.0.4 (from oci_cli) Downloading https://files.pythonhosted.org/packages/c0/ed/863422c99e4cdf567e98767812886197abbd455d79d2f71ab9d7c93be77f/oci-2.0.4-py2.py3-none-any.whl (1.4MB) 100% |████████████████████████████████| 1.4MB 6.8MB/s Collecting terminaltables==3.1.0 (from oci_cli) Downloading https://files.pythonhosted.org/packages/9b/c4/4a21174f32f8a7e1104798c445dacdc1d4df86f2f26722767034e4de4bff/terminaltables-3.1.0.tar.gz Collecting retrying==1.3.3 (from oci_cli) Downloading https://files.pythonhosted.org/packages/44/ef/beae4b4ef80902f22e3af073397f079c96969c69b2c7d52a57ea9ae61c9d/retrying-1.3.3.tar.gz Collecting python-dateutil==2.7.3 (from oci_cli) Downloading https://files.pythonhosted.org/packages/cf/f5/af2b09c957ace60dcfac112b669c45c8c97e32f94aa8b56da4c6d1682825/python_dateutil-2.7.3-py2.py3-none-any.whl (211kB) 100% |████████████████████████████████| 215kB 25.0MB/s Collecting asn1crypto>=0.21.0 (from cryptography==2.1.3->oci_cli) Downloading https://files.pythonhosted.org/packages/ea/cd/35485615f45f30a510576f1a56d1e0a7ad7bd8ab5ed7cdc600ef7cd06222/asn1crypto-0.24.0-py2.py3-none-any.whl (101kB) 100% |████████████████████████████████| 102kB 13.4MB/s Collecting cffi>=1.7; platform_python_implementation != "PyPy" (from cryptography==2.1.3->oci_cli) Downloading https://files.pythonhosted.org/packages/6d/c0/47db8f624f3e4e2f3f27be03a93379d1ba16a1450a7b1aacfa0366e2c0dd/cffi-1.11.5-cp36-cp36m-manylinux1_x86_64.whl (421kB) 100% |████████████████████████████████| 430kB 23.6MB/s Collecting pyOpenSSL<=17.4.0 (from oci==2.0.4->oci_cli) Downloading https://files.pythonhosted.org/packages/b7/45/0b83f445994da6ff803d7c3a5fa016afda3c965d0c48dafa8e0264a554e7/pyOpenSSL-17.4.0-py2.py3-none-any.whl (52kB) 100% |████████████████████████████████| 61kB 10.1MB/s Collecting pycparser (from cffi>=1.7; platform_python_implementation != "PyPy"->cryptography==2.1.3->oci_cli) Downloading https://files.pythonhosted.org/packages/68/9e/49196946aee219aead1290e00d1e7fdeab8567783e83e1b9ab5585e6206a/pycparser-2.19.tar.gz (158kB) 100% |████████████████████████████████| 163kB 16.9MB/s Building wheels for collected packages: arrow, configparser, terminaltables, retrying, pycparser Running setup.py bdist_wheel for arrow ... done Stored in directory: /tmp/tmp4stdxpko/wheels/ce/4f/95/64541c7466fd88ffe72fda5164f8323c91d695c9a77072c574 Running setup.py bdist_wheel for configparser ... done Stored in directory: /tmp/tmp4stdxpko/wheels/a3/61/79/424ef897a2f3b14684a7de5d89e8600b460b89663e6ce9d17c Running setup.py bdist_wheel for terminaltables ... done Stored in directory: /tmp/tmp4stdxpko/wheels/30/6b/50/6c75775b681fb36cdfac7f19799888ef9d8813aff9e379663e Running setup.py bdist_wheel for retrying ... done Stored in directory: /tmp/tmp4stdxpko/wheels/d7/a9/33/acc7b709e2a35caa7d4cae442f6fe6fbf2c43f80823d46460c Running setup.py bdist_wheel for pycparser ... done Stored in directory: /tmp/tmp4stdxpko/wheels/f2/9a/90/de94f8556265ddc9d9c8b271b0f63e57b26fb1d67a45564511 Successfully built arrow configparser terminaltables retrying pycparser Installing collected packages: six, python-dateutil, arrow, pytz, idna, certifi, asn1crypto, pycparser, cffi, cryptography, click, httpsig-cffi, configparser, jmespath, pyOpenSSL, oci, terminaltables, retrying, oci-cli Successfully installed arrow-0.10.0 asn1crypto-0.24.0 certifi-2018.8.24 cffi-1.11.5 click-6.7 configparser-3.5.0 cryptography-2.1.3 httpsig-cffi-15.0.0 idna-2.6 jmespath-0.9.3 oci-2.0.4 oci-cli-2.4.33 pyOpenSSL-17.4.0 pycparser-2.19 python-dateutil-2.7.3 pytz-2016.10 retrying-1.3.3 six-1.11.0 terminaltables-3.1.0 ===> Modify profile to update your $PATH and enable shell/tab completion now? (Y/n): Y ===> Enter a path to an rc file to update (leave blank to use '/home/oracle/.bashrc'): -- Backed up '/home/oracle/.bashrc' to '/home/oracle/.bashrc.backup' -- Tab completion set up complete. -- If tab completion is not activated, verify that '/home/oracle/.bashrc' is sourced by your shell. -- -- ** Run `exec -l $SHELL` to restart your shell. ** -- -- Installation successful. -- Run the CLI with /home/oracle/kube/bin/oci --help [email protected]:~/kube/oci-cli$
Restart Shell
[email protected]:~/kube/oci-cli$ oci ce cluster Command 'oci' not found, did you mean: command 'sci' from deb scheme2c command 'ci' from deb rcs command 'ori' from deb ori command 'ocp' from deb opencubicplayer command 'ocs' from deb cscope Try: sudo apt install [email protected]:~/kube/oci-cli$ exec -l $SHELL [email protected]:~/kube/oci-cli$ oci ce cluster Usage: oci ce cluster [OPTIONS] COMMAND [ARGS]... A Kubernetes cluster. Options: -?, -h, --help Show this message and exit. Commands: create Create a new cluster. create-kubeconfig Create the Kubeconfig YAML for a cluster. delete Delete a cluster. get Get the details of a cluster. list List all the cluster objects in a... update Update the details of a cluster. [email protected]:~/kube/oci-cli$
We are good to go now , OCI CLI commands are working
Create Basic CLI Config File
[email protected]:~/kube$ [email protected]:~$ oci setup oci-cli-rc --file /home/oracle/.oci/config Predefined queries written under section OCI_CLI_CANNED_QUERIES Command aliases written under section OCI_CLI_COMMAND_ALIASES Parameter aliases written under section OCI_CLI_PARAM_ALIASES [email protected]:~$ oci os bucket list --cli-rc-file /home/oracle/.oci/config WARNING: Permissions on /home/oracle/.oci/config are too open. To fix this please execute the following command: oci setup repair-file-permissions --file /home/oracle/.oci/config ERROR: The config file at ~/.oci/config is invalid: +Config Errors+---------+----------------------------------------------------------------------------------+ | Key | Error | Hint | +-------------+---------+----------------------------------------------------------------------------------+ | key_file | missing | the full path and filename of the private PEM key file | | user | missing | log into the console and go to the user's settings page to find their OCID | | fingerprint | missing | openssl rsa -pubout -outform DER -in | openssl md5 -c | | tenancy | missing | log into the console and find this OCID at the bottom of any page | | region | missing | for example, us-phoenix-1 | +-------------+---------+----------------------------------------------------------------------------------+ [email protected]:~$ cat /home/oracle/.oci/config [OCI_CLI_CANNED_QUERIES] # For list results, this gets the ID and display-name of each item in the list. Note that when the names of attirbutes have # dashes in them they need to be surrounded with double quotes. This query knows to look for a list because of the # [*] syntax get_id_and_display_name_from_list=data[*].{id: id, "display-name": "display-name"} get_id_and_display_name_from_single_result=data.{id: id, "display-name": "display-name"} # Retrieves a comma separated string, for example: # ocid1.instance.oc1.phx.xyz....,cli_test_instance_675195,RUNNING get_id_display_name_and_lifecycle_state_from_single_result_as_csv=data.[id, "display-name", "lifecycle-state"] | join(`,`, @) # Retrieves comma separated strings from a list of results get_id_display_name_and_lifecycle_state_from_list_as_csv=data[*].[join(`,`, [id, "display-name", "lifecycle-state"])][] # Filters where the display name contains some text filter_by_display_name_contains_text=data[?contains("display-name", `your_text_here`)] # Filters where the display name contains some text and pull out certain attributes(id and time-created) filter_by_display_name_contains_text_and_get_attributes=data[?contains("display-name", `your_text_here`)].{id: id, timeCreated: "time-created"} # Get the top 5 results from a list operation get_top_5_results=data[:5] # Get the last 2 results from a list operation get_last_2_results=data[-2:] # List instance public IPs from list vnics response # Example: oci compute instance list-vnics --instance-id $I --query query://list_public_ips list_public_ips=data[?"public-ip" != null]."public-ip" # Get first public IP from list vnics response # Example: oci compute instance list-vnics --instance-id $I --query query://get_public_ip get_public_ip=data[?"public-ip" != null]."public-ip" | [0] [OCI_CLI_COMMAND_ALIASES] # This lets you use "ls" instead of "list" for any list command in the CLI ls = list # This lets you do "oci os object rm" rather than "oci os object delete". This is an example of a "command sequence alias", where the alias on the left # hand side only applies when the command sequence on the right hand side is invoked. You can think of these as being of the form: # = . # # So in our example, = rm, = os object, = delete rm = os.object.delete [OCI_CLI_PARAM_ALIASES] # Parameter aliases either need to start with a double dash (--) or be a single dash (-) followed by a single letter. For example: --foo, -f --ad = --availability-domain --dn = --display-name --egress-rules = --egress-security-rules --ingress-rules = --ingress-security-rules
[email protected]:~$ cat /home/oracle/.oci/config [OCI_CLI_SETTINGS] default_profile=IAD [DEFAULT] region=us-ashburn-1 tenancy=ocid1.tenancy.oc1..aaaaaaaaz6nxhjcw6vklojXXXXXXXwlgrdzzcpbxp63oaafb6thjew2q user=ocid1.user.oc1..aaaaaaaaqwpi4frv2z5ojihv6yXXXXXXXXb7mv3ypxqauj6srca key_file=/home/oracle/kube/ocikeys/oci_api_key.pem fingerprint=73:09:ff:fa:dc:4a:af:00:a0:98:df:32:33:0b:a9:88 [OCI_CLI_CANNED_QUERIES] # For list results, this gets the ID and display-name of each item in the list. Note that when the names of attirbutes have # dashes in them they need to be surrounded with double quotes. This query knows to look for a list because of the # [*] syntax get_id_and_display_name_from_list=data[*].{id: id, "display-name": "display-name"} get_id_and_display_name_from_single_result=data.{id: id, "display-name": "display-name"} # Retrieves a comma separated string, for example: # ocid1.instance.oc1.phx.xyz....,cli_test_instance_675195,RUNNING get_id_display_name_and_lifecycle_state_from_single_result_as_csv=data.[id, "display-name", "lifecycle-state"] | join(`,`, @) # Retrieves comma separated strings from a list of results get_id_display_name_and_lifecycle_state_from_list_as_csv=data[*].[join(`,`, [id, "display-name", "lifecycle-state"])][] # Filters where the display name contains some text filter_by_display_name_contains_text=data[?contains("display-name", `your_text_here`)] # Filters where the display name contains some text and pull out certain attributes(id and time-created) filter_by_display_name_contains_text_and_get_attributes=data[?contains("display-name", `your_text_here`)].{id: id, timeCreated: "time-created"} # Get the top 5 results from a list operation get_top_5_results=data[:5] # Get the last 2 results from a list operation get_last_2_results=data[-2:] # List instance public IPs from list vnics response # Example: oci compute instance list-vnics --instance-id $I --query query://list_public_ips list_public_ips=data[?"public-ip" != null]."public-ip" # Get first public IP from list vnics response # Example: oci compute instance list-vnics --instance-id $I --query query://get_public_ip get_public_ip=data[?"public-ip" != null]."public-ip" | [0] [OCI_CLI_COMMAND_ALIASES] # This lets you use "ls" instead of "list" for any list command in the CLI ls = list # This lets you do "oci os object rm" rather than "oci os object delete". This is an example of a "command sequence alias", where the alias on the left # hand side only applies when the command sequence on the right hand side is invoked. You can think of these as being of the form: # = . # # So in our example, = rm, = os object, = delete rm = os.object.delete [OCI_CLI_PARAM_ALIASES] # Parameter aliases either need to start with a double dash (--) or be a single dash (-) followed by a single letter. For example: --foo, -f --ad = --availability-domain --dn = --display-name --egress-rules = --egress-security-rules --ingress-rules = --ingress-security-rules [email protected]:~$
fix the file permissions
[email protected]:~$ oci setup repair-file-permissions --file /home/oracle/.oci/config
Configuring the config file /home/oracle/.oci/config
Get Tenancy ID
Get User ID and User
Here User is [email protected]
OCID can be copied
GET REGION
Region is part of URL
https://console.us-ashburn-1.oraclecloud.com/a
in our case region is ashburn-1
GET FingerPrint
Edit the CLI Configuration file by adding the 8 lines as shown below
[OCI_CLI_SETTINGS] default_profile=IAD [DEFAULT] region=us-ashburn-1 tenancy=ocid1.tenancy.oc1..aaaaaaaazXXXXXlojqv7icrrdzzcpbxp63oaafb6thjew2q user=ocid1.user.oc1..aaaaaaaaqwpi4frXXXXXvbe6e73ed7nwb7mv3ypxqauj6srca key_file=/home/oracle/kube/ocikeys/oci_api_key.pem fingerprint=73:09:ff:fa:dc:4a:af:XXXXX.f:32:33:0b:a9:88 [OCI_CLI_CANNED_QUERIES] # For list results, this gets the ID and display-name of each item in the list. Note that when the names of attirbutes have # dashes in them they need to be surrounded with double quotes. This query knows to look for a list because of the # [*] syntax get_id_and_display_name_from_list=data[*].{id: id, "display-name": "display-name"} get_id_and_display_name_from_single_result=data.{id: id, "display-name": "display-name"} # Retrieves a comma separated string, for example: # ocid1.instance.oc1.phx.xyz....,cli_test_instance_675195,RUNNING get_id_display_name_and_lifecycle_state_from_single_result_as_csv=data.[id, "display-name", "lifecycle-state"] | join(`,`, @) # Retrieves comma separated strings from a list of results get_id_display_name_and_lifecycle_state_from_list_as_csv=data[*].[join(`,`, [id, "display-name", "lifecycle-state"])][] # Filters where the display name contains some text filter_by_display_name_contains_text=data[?contains("display-name", `your_text_here`)] # Filters where the display name contains some text and pull out certain attributes(id and time-created) filter_by_display_name_contains_text_and_get_attributes=data[?contains("display-name", `your_text_here`)].{id: id, timeCreated: "time-created"} # Get the top 5 results from a list operation get_top_5_results=data[:5] # Get the last 2 results from a list operation get_last_2_results=data[-2:] # List instance public IPs from list vnics response # Example: oci compute instance list-vnics --instance-id $I --query query://list_public_ips list_public_ips=data[?"public-ip" != null]."public-ip" # Get first public IP from list vnics response # Example: oci compute instance list-vnics --instance-id $I --query query://get_public_ip get_public_ip=data[?"public-ip" != null]."public-ip" | [0] [OCI_CLI_COMMAND_ALIASES] # This lets you use "ls" instead of "list" for any list command in the CLI ls = list # This lets you do "oci os object rm" rather than "oci os object delete". This is an example of a "command sequence alias", where the alias on the left # hand side only applies when the command sequence on the right hand side is invoked. You can think of these as being of the form: # = . # # So in our example, = rm, = os object, = delete rm = os.object.delete [OCI_CLI_PARAM_ALIASES] # Parameter aliases either need to start with a double dash (--) or be a single dash (-) followed by a single letter. For example: --foo, -f --ad = --availability-domain --dn = --display-name --egress-rules = --egress-security-rules --ingress-rules = --ingress-security-rules
Run the below oci ce cluster create-kubeconfig command The Below command should now Auto Generate kubeconfig file
[email protected]:~$ oci ce cluster create-kubeconfig --cluster-id ocid1.cluster.oc1.iad.aaaaaaaaafrdsmjwgqztimzsg43wgnbxgjrtsodbmmzdqy ztmctgeoddgrsd --file $HOME/kubernetes/kubeconfig
this should run without errors and autogenerate kubeconfig file
[email protected]:~/kube/kubernetes$ cat kubeconfig apiVersion: v1 clusters: - cluster: certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJQ0.... GSUNBVEUtLS0tLQo= server: https://ctgeoddgrsd.us-ashburn-1.clusters.oci.oraclecloud.com:6443 name: cluster-ctgeoddgrsd contexts: - context: cluster: cluster-ctgeoddgrsd user: user-ctgeoddgrsd name: context-ctgeoddgrsd current-context: context-ctgeoddgrsd kind: "" users: - name: user-ctgeoddgrsd user: token: eyJoZWFkZXIiOnsiQXV0aG9yaXphdGlv....
Getting Kubectl version and Get Nodes
[email protected]:~$ export KUBECONFIG=$HOME/kubernetes/kubeconfig [email protected]:~$ kubectl get nodes NAME STATUS ROLES AGE VERSION 129.213.148.25 Ready node 2h v1.11.1 129.213.39.155 Ready node 2h v1.11.1 132.145.175.245 Ready node 2h v1.11.1 [email protected]:~$ kubectl version Client Version: version.Info{Major:"1", Minor:"12", GitVersion:"v1.12.0", GitCommit:"0ed33881dc4355495f623c6f22e7dd0b7632b7c0", GitTreeState:"clean", BuildDate:"2018-09-27T17:05:32Z", GoVersion:"go1.10.4", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"11+", GitVersion:"v1.11.1-2+e49fe6296d12ea", GitCommit:"e49fe6296d12ea823430bb7bda457d1201b17277", GitTreeState:"clean", BuildDate:"2018-07-24T14:24:53Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
What next >> Getting Kubernetes Dashboard
User Submitted Errors
[email protected]:/# oci ce cluster create-kubeconfig --cluster-id ocid1.cluster.oc1.iad.aaaaaaaaae4tezjvmm3gXXXzjqhXXXobx gctdsmjzgrsd --file $HOME/kubernetes/kubeconfig3 MissingSectionHeaderError: File contains no section headers. file: '/root/.oci/config', line: 1 'OCI_CLI_SETTINGS]\n' [email protected]:/# Solution : Errors in the Config File /home/oracle/.oci/config , [ Missing
References
Install kubectl https://kubernetes.io/docs/tasks/tools/install-kubectl/KubeCTL
Install CLI https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/cliinstall.htmCLI
Configure CLI https://docs.cloud.oracle.com/iaas/Content/API/SDKDocs/cliconfigure.htm
Generating Keys https://docs.cloud.oracle.com/iaas/Content/API/Concepts/apisigningkey.htm#How