Thursday, January 17, 2019

Tip To Upload Files Into OCI Object Storage with Pre-Authenticated Requests

Symptom:

 Sometimes we need to provide many files to customers and customers need to provide files to us.
We can use OCI Object Storage Pre-Authenticated Requests to share data. Please refer more details on  Oracle Blog
    However after I create bucket Pre-Authenticated Requests , copy and paste url into our browser, we get below error

{"code":"NotFound","message":"Not Found"}

Solution:

The object Pre-Authenticated Requests can be writing or reading or both. 
The bucket Pre-Authenticated Requests is for writing purpose only (not reading)
So we need to use curl or other tools to put objects into the bucket. ie

curl https://objectstorage.us-ashburn-1.oraclecloud.com/p/THVqAQC1oIiwmerj6aK1lY5q3xG-rK3iGZvM2b1kq0/n/testtest/b/testdata/o/ --upload-file  mydata.tar

Wednesday, January 16, 2019

How To Deal With Dep Ensure Issue

Symptom:

When we create a new project in golang, we run "dep ensure" and get below error:
dep ensure
Solving failure: No versions of k8s.io/gengo met constraints:
        master: unable to update checked out version: fatal: reference is not a tree: f8a0810f38afb8478882b3835a615aebfda39afa
: command failed: [git checkout f8a0810f38afb8478882b3835a615aebfda39afa]: exit status 128

Solution:

Use "dep ensure -v"  to get debug information and find out which packages have check out issues
In this example, k8s.io/gengo  has issues.

It is very likely  dep cache corrupted on this package when new version of our apps or tools being added 

We need to delete dep cache of k8s.io/gengo

rm -rf  $GOPATH/go/dep/source/https---github.com-kubernetes-gengo

rerun dep ensure


Friday, January 04, 2019

How To Duplicate an Application in K8S to Another K8S Cluster

Please refer github note

How To Install MiniKube Inside Linux

Requirement

  • Make sure your linux  CPU has vmx svm supported. run below to check. If none return, it means your linux does not support refer doc 
 egrep '(vmx|svm)' /proc/cpuinfo
  • Otherwise you may get error like
E0830 20:33:53.017334   30356 start.go:174] Error starting host: Error creating host: Error creating machine: Error in driver during machine creation: creating domain: Error defining domain xml:

Install kubectl first

  • setup your proxy on the OS if it is behind firewall
add this into .bash_profile
export http_proxy=http://www-proxy.us.test.com:80/
export https_proxy=http://www-proxy.us.test.com:80/
  • download kubectl from google which is only 1 big file
  • curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl
  • chmod +x ./kubectl
  • mv ./kubectl  /usr/bin/kubectl
  • test it to run : kubectl version to see any output. example like 
# kubectl version
    Client Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.2", GitCommit:"bb9ffb1654d4a729bb4cec18ff088eacc153c239", GitTreeState:"clean", BuildDate:"2018-08-07T23:17:28Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"}
      The connection to the server localhost:8080 was refused - did you specify the right host or port?
      • connection refused error can be ignored
      • refer doc 

      Install KVM2 Driver&Start Libvirtd Service for virutal machine

      • refer doc
      • #yum install libvirt
      • #yum install libvirt-daemon-kvm qemu-kvm
      • # newgrp libvirt
      • # usermod -a -G libvirt $(whoami)
      •  systemctl start  libvirtd.service
      • download driver from google
      # curl -Lo docker-machine-driver-kvm2 https://storage.googleapis.com/minikube/releases/latest/docker-machine-driver-kvm2 \
      && chmod +x docker-machine-driver-kvm2 \
      && sudo cp docker-machine-driver-kvm2 /usr/bin/ \
      && rm docker-machine-driver-kvm2

      Install / Start minikube 

      • refer doc
      • download minikube which is only 1 file
      • curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.28.2/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/bin/
       #minikube version
      minikube version: v0.28.2

      • # minikube start   --vm-driver kvm2
      Starting local Kubernetes v1.10.0 cluster...
      Starting VM...
      Downloading Minikube ISO
       160.27 MB / 160.27 MB [============================================] 100.00% 0s
      Getting VM IP address...
      Moving files into cluster...
      Downloading kubeadm v1.10.0
      Downloading kubelet v1.10.0
      Finished Downloading kubelet v1.10.0
      Finished Downloading kubeadm v1.10.0
      Setting up certs...
      Connecting to cluster...
      Setting up kubeconfig...
      Starting cluster components...

      Thursday, January 03, 2019

      How To Add Self-Signed Certificate in Oracle OCI Loadbalancer

      Requirement:

        Sometimes when we create a test environment,  we need to set SSL/TLS while we don't wanna go through the process to get official SSL/TLS CA which takes much time.
        So we can genearete self-signed Certificate and import it into OCI load balancer

      Solution:

        Refer Oracle OCI  official doc
         Use openssl to generate Certificate and Private key ( we don't need CA Authority for test)

      # openssl req -x509 -newkey rsa:4096 -sha256 -days 3650 -nodes -keyout test.key -out test.crt -subj '/CN=test.com' 

      test.key  :  Private Key file
      test.crt : Certificate file

      In OCI load balancer , click "add certificate" button, examples like


      PASSPHASE: can be empty

      Once it is added, we can apply it on OCI load balancer