Tagged KUBECTL

Deploying a Coherence Cluster in Kubernetes


Coherence-Operator is a Kubernetes opeartor for deploying Oracle Coherence in k8s. Let’s see how to do it.

1 Clean previous setup intents:

helm del --purge sample-coherence
helm del --purge sample-coherence-operator
kubectl delete namespace sample-coherence-ns

2 Execute the following:

kubectl config set-context $(kubectl config current-context) --namespace=sample-coherence-ns

helm repo add coherence https://oracle.github.io/coherence-operator/charts

helm repo update

helm --debug install coherence/coherence-operator --name sample-coherence-operator --set "targetNamespaces={}" --set imagePullSecrets=sample-coherence-secret

helm ls

helm status sample-coherence-operator

3 Create a secret with your credentials to Oracle Container Registry:

kubectl create secret docker-registry oracle-container-registry-secret --docker-server=container-registry.oracle.com --docker-username='youruser' --docker-password='yourpasswd' --docker-email='youremail'

4 Install:

helm --debug install coherence/coherence --name sample-coherence --set imagePullSecrets=oracle-container-registry-secret

5 Proxy to a pod:

export POD_NAME=$(kubectl get pods --namespace sample-coherence-ns -l "app=coherence,release=sample-coherence,component=coherencePod" -o jsonpath="{.items[0].metadata.name}")

kubectl --namespace sample-coherence-ns port-forward $POD_NAME 20000:20000

6 Download and install Coherence Stand Alone

7 Download this and this

8 Build the client:

export COHERENCE_HOME=~/Oracle/Middleware/Oracle_Home/coherence
javac -cp .:${COHERENCE_HOME}/lib/coherence.jar HelloCoherence.javaexport COHERENCE_HOME=~/Oracle/Middleware/Oracle_Home/coherence

9 Test it:

java -cp .:${COHERENCE_HOME}/lib/coherence.jar -Dcoherence.cacheconfig=$PWD/example-client-config.xml HelloCoherence

2019-07-11 01:21:33.575/0.538 Oracle Coh...

…

Oracle Coherence Version 12.2.1.3.0 Build 68243

2019-07-11 01:21:34.430/1.392 Oracle 

The value of the key is 7

That’s all, hope it helps 🙂

Deploying an Oracle Database with Persistence Enabled in Oracle Kubernetes Engine in Ten Minutes or Less


In a previous post I explained how to create the same thing using an image published in docker registry under my user. Well… that post is not working anymore because I deleted the image for some reasons.

The method exposed here is better because the deployment file pulls the official image published here.

Therefore you only have to create a user, accept the licence agreement (just in case you acknowledge it) and follow the steps explained here.

Hope it helps! 😉

 

Containerizing​ kubectl for working with OKE (Oracle Kubernetes Engine)


kubectl is one of the command line interfaces for managing k8s. In this post, we are containerizing kubectl for easy utilization across different environments.

Because kubectl in OKE is related with OCI CLI, we are setting up the kubectl tool by adding it to ocloudshell container we created in this post.

STEP 1

Configure OCI CLI as mentioned in the referenced post

STEP 2

Download kubectl and put it in the ocloudshell directory
curl -LO https://storage.googleapis.com/kubernetes-release/release/v1.12.0/bin/linux/amd64/kubectl

STEP 3

Configure kubectl for OKE following instructions you can find in the main page of each K8s cluster created in the OCI dashboard UI:

kubeconfig

STEP 4

Copy the .kube directory created in your home directory to the ocloudshell directory

STEP 5

Create Dockerfile

FROM store/oracle/serverjre:8
ENV LC_ALL=en_US.utf8 \
LANG=en_US.utf8
ARG OPC_CLI_VERSION=18.1.2
ENV OPC_CLI_PKG=opc-cli-$OPC_CLI_VERSION.zip
WORKDIR /ocloudshell/
RUN curl -o /etc/yum.repos.d/public-yum-ol7.repo http://yum.oracle.com/public-yum-ol7.repo \
&& yum-config-manager --enable ol7_developer_EPEL \
&& yum-config-manager --enable ol7_developer \
&& yum -y install unzip python-oci-cli \
&& rm -rf /var/cache/yum/*
WORKDIR /root
ADD .oci/ .oci/
RUN chmod 400 .oci/config
RUN chmod 400 .oci/oci_api_key.pem
ADD .kube/ .kube/
ADD kubectl /usr/local/bin/kubectl
RUN chmod +x /usr/local/bin/kubectl
CMD ["/bin/bash"]

STEP 6

Create and push the container to a private repo*
docker build -t yourrepo/ocloudshell .

docker push yourrepo/ocloudshell
(*) Remember, don’t push to public repo or you are putting in serious risk your environment!!

TEST IT

So far, so good. Let’s test the container executing a command, for instance:

docker run -it javiermugueta/ocloudshell kubectl get po

That’s all folks!

Enjoy 🙂