Skip to content

Instantly share code, notes, and snippets.

View lucasjellema's full-sized avatar

Lucas Jellema lucasjellema

View GitHub Profile
#!/bin/bash
# in order to run, first install jq with: sudo apt-get install jq
oci() { docker run --rm --mount type=bind,source=$HOME/.oci,target=/root/.oci stephenpearson/oci-cli:latest "$@"; }
# set global variable OKE_COMPARTMENT_ID with the OCID for the compartment with name passed in $1
set_oke_compartment()
{
echo set_oke_compartments for $1
compartments=$(oci iam compartment list --compartment-id $ROOT_COMPARTMENT_ID --all)
# echo "Compartments: $compartments"
@lucasjellema
lucasjellema / ociCommandsForCreatingResourcesForOKE.sh
Created October 20, 2018 09:11
This gist provides all OCI CLI calls to prepare the network resources in an OCI compartment that will then allow an OKE Cluster instance to be instantiated
Export the OCID of the root compartment:
export ROOT_COMPARTMENT_ID=ocid1.tenancy.oc1..aaaaaaaaot
Create a new OKE policy in the root compartment of your tenancy:
oci iam policy create --name oke-service --compartment-id $ROOT_COMPARTMENT_ID --statements '[ "allow service OKE to manage all-resources in tenancy"]' --description 'policy for granting rights on OKE to manage cluster resources'
List all policies, to verify the success of the creation:
oci iam policy list --compartment-id $ROOT_COMPARTMENT_ID --all
Now create a special compartment for all OKE resources
@lucasjellema
lucasjellema / welcome.sh
Last active December 18, 2019 14:50
Example of how to call a function in a Linux Shell Script - passing in input parameters and receiving the result from the function (in a way that resembles modern programming languages)
# a global variable
WELCOME_ROOT=Hello
# invoke this function with two arguments:
# 1. (FROM_VAR) the name of the greeter
# 2. (TO_VAR) the name of the greetee
# this function returns a welcoming message
get_welcoming_message()
{
FROM_VAR=$1
const debug = function (debugBuffer, msg) {
// using the full UTC string is a bit heavy handed perhaps; only minutes, seconds and ms would be quite enough, or just the timestamp in ms
debugBuffer.push(`${new Date().toUTCString()} ${msg}`)
}
const spillDebugBeans = function (debugBuffer) {
debugBuffer.forEach(msg => { console.log(`DEBUG: ${msg}`) });
}// spillDebugBeans
const calculateSums = async function (sums) {
@lucasjellema
lucasjellema / debug-upon-error-2.js
Created July 7, 2020 14:41
Collect debug messages to only print to output when an exception occurs
const debugBuffer = []
const savepoints = {}
const debug = function (msg) {
// using the full UTC string is a bit heavy handed perhaps; only minutes, seconds and ms would be quite enough, or just the timestamp in ms
debugBuffer.push(`${new Date().toUTCString()} ${msg}`)
}
const setSavepoint = function (savepoint) {
savepoints[savepoint] = debugBuffer.length
@lucasjellema
lucasjellema / functions.tf
Created November 29, 2021 21:42
terraform composite for function on OCI
### Repository in the Container Image Registry for the container images underpinning the function
resource "oci_artifacts_container_repository" "container_repository_for_function" {
# note: repository = store for all images versions of a specific container image - so it included the function name
compartment_id = var.compartment_ocid
display_name = "${local.ocir_repo_name}/${var.function_name}"
is_immutable = false
is_public = false
}
resource "null_resource" "Login2OCIR" {
@lucasjellema
lucasjellema / query.tf
Created December 2, 2021 07:34
quick-terraform-oci-initialization
terraform {
required_version = ">= 0.14"
}
provider oci {
region = var.region
}
variable tenancy_ocid {default = "the ocid of your tenancy"}
variable region {default = "the region in which you want to query"}
@lucasjellema
lucasjellema / query.tf
Last active December 2, 2021 07:40
terraform-oci-query-functions-in-application
variable "application_name" { default = "cloudnative-2021App"}
data "oci_functions_applications" "function_applications" {
compartment_id = var.compartment_id
display_name = "${var.application_name}"
}
data "oci_functions_functions" "application_functions" {
application_id = data.oci_functions_applications.function_applications.applications[0].id
}
@lucasjellema
lucasjellema / commands.md
Last active December 12, 2021 12:46
OKE-dashboard-app-deployment

Get Kubernetes Dashboard Running

Install Dashboard on Cluster kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.4.0/aio/deploy/recommended.yaml

Verify the deployment kubectl -n kubernetes-dashboard get pods

Proxy Cluster kubectl proxy

@lucasjellema
lucasjellema / main.go
Last active December 28, 2021 12:08
OCI Go SDK ObjectStorag explorations
package main
import (
"context"
"fmt"
"io"
"io/ioutil"
"log"
"net/http"
"os"