<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Fernando Harris on Medium]]></title>
        <description><![CDATA[Stories by Fernando Harris on Medium]]></description>
        <link>https://medium.com/@HarrisNando?source=rss-b6254430356c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*oSOCWexMYUBXq15m.jpg</url>
            <title>Stories by Fernando Harris on Medium</title>
            <link>https://medium.com/@HarrisNando?source=rss-b6254430356c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 25 Nov 2026 01:21:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@HarrisNando/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[GPU sharing with MPS and OKE]]></title>
            <link>https://medium.com/oracledevs/gpu-sharing-with-mps-and-oke-882048ed364e?source=rss-b6254430356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/882048ed364e</guid>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[nvidia]]></category>
            <category><![CDATA[gpu]]></category>
            <dc:creator><![CDATA[Fernando Harris]]></dc:creator>
            <pubDate>Tue, 06 May 2025 17:10:47 GMT</pubDate>
            <atom:updated>2025-12-16T13:38:13.181Z</atom:updated>
            <content:encoded><![CDATA[<p>Though I’ve been working with Kubernetes since 2018, only very recently I had the opportunity to learn a bit more about <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengrunninggpunodes.htm">GPU-based worker nodes</a>.</p><p>The GPU concept was familiar in the past for those well versed on gaming for instance. But now, it is basically a new “computing” commodity, without which mega advents such as AI wouldn’t be possible.</p><p>When working with Kubernetes, the most common use cases still rely on regular CPU-based worker nodes. As we all know, the CPU is the primary unit responsible to processes logic and is typically dependent of a few cores to manage a relatively low number of threads at a time. This brings some limitations for data intensive activities on Kubernetes and the GPU-based worker nodes can be a solution. GPUs are composed of hundreds of cores and are able to manage thousands of threads in parallel or simultaneously.</p><h3>GPU-based worker nodes on OKE</h3><p>In OKE, if we want to run applications on GPU-based worker nodes all we have to do is to select a GPU shape and compatible GPU image for a new node pool. However, GPU-based worker nodes can be significantly more expensive then CPU-based. This creates the need to use them wisely and efficiently. Like for instance by increasing the number of applications/pods that can concurrently make use of the available GPU resources.</p><p>For this type of situation, GPU supports “sharing”.</p><h3>GPU sharing</h3><p>We can use two different approaches to achieve GPU sharing: <strong>Time-Slicing </strong>and<strong> MPS</strong>. Time-Slicing is out of scope for this blog, but you can find more information <a href="https://github.com/NVIDIA/k8s-device-plugin?tab=readme-ov-file#with-cuda-mps">here</a>. By the way, Time-slicing and MPS are mutually exclusive.</p><p>MPS stands for <strong>Multi-Process Service</strong> and its “<em>runtime architecture is designed to transparently enable co-operative multi-process CUDA applications</em>”.</p><p>Before trying it, please remember that as of <em>v0.15.0, </em>Nvidia considers MPS to be on an experimental phase and what we present on this blog is merely an exploratory exercise<em>. </em>My recommendation is to wait for official production ready support from Nvidia before trying these exercises in production.</p><h3>Configure MPS on OKE</h3><p>This example is based on OKE and GPU shape of type VM.GPU.A10.1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xklug5_icRzJK7-I83CPIQ.png" /></figure><p>We will need to prepare the GPU worker nodes according to Nvidia official documentation <a href="https://github.com/NVIDIA/k8s-device-plugin?tab=readme-ov-file#with-cuda-mps">here</a>. But before creating this GPU node pool, make sure you have already created a Node Pool to manage non-GPU related workloads like the pods and daemon sets from kube-system and some other pods and resources which will eventually be created by the k8s-device-plugin.</p><p>The cleanest way to prepare the GPU-based worker nodes, is by using a<a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengusingcustomcloudinitscripts.htm"> <strong>cloud init script</strong></a>, which can be used in the <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengusingcustomcloudinitscripts.htm#contengusingcustomcloudinitscripts_topic_Using_the_Console">console</a>, as we will be showing next, but can also be easily invoked from Terraform or with <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengusingcustomcloudinitscripts.htm#contengusingcustomcloudinitscripts_topic_Using_the_CLI">OCI CLI</a>.</p><p>In the console, after clicking <strong>Add Node</strong>, select a GPU shape that supports MPS:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GsWdemnan3BebpPfwYG7qg.png" /></figure><p>Then click <strong>Show Advanced options </strong>and find the <strong>Initialization script</strong> box to past the code below:</p><pre>#!/bin/bash<br>curl --fail -H &quot;Authorization: Bearer Oracle&quot; -L0 http://169.254.169.254/opc/v2/instance/metadata/oke_init_script | base64 --decode &gt;/var/run/oke-init.sh<br>bash /var/run/oke-init.sh<br>sudo yum install -y nvidia-container-toolkit<br>sudo nvidia-ctk runtime configure --runtime=crio --set-as-default --config=/etc/crio/crio.conf.d/99-nvidia.conf<br>sudo systemctl restart crio</pre><p>The first line immediately after <em>bash /var/run/oke-init.sh will </em><a href="https://github.com/NVIDIA/k8s-device-plugin?tab=readme-ov-file#install-the-nvidia-container-toolkit">install with yum the Nvidia container toolkit.</a></p><p>The following line sets the container runtime as <strong>cri-o</strong> as OKE worker nodes container engines run with cri-o. We then add the config file to set the nvidia-container-runtime as the default low-level OCI runtime under /etc/crio/crio.conf.d/99-nvidia.conf. This will take priority over the default crun config file at /etc/crio/crio.conf.d/10-crun.conf</p><p>Finally, the last line restarts the cri-o service.</p><p>You should now have something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ccw0JwRD6jzOOOqMiyHSQQ.png" /></figure><p><strong>Add </strong>the node pool.</p><p>Once the GPU-based worker node is <strong>active</strong> and <strong>ready</strong>, we can install the Nvidia device plugin on the cluster. Take a look at the GitHub documentation <a href="https://github.com/NVIDIA/k8s-device-plugin">here</a>. If you want to deploy it with helm as we show below, find the complete documentation <a href="https://github.com/NVIDIA/k8s-device-plugin?tab=readme-ov-file#deployment-via-helm">here</a>:</p><pre>helm repo add nvdp https://nvidia.github.io/k8s-device-plugin<br>helm repo update</pre><p><strong>MPS Configuration :</strong></p><p>Lets now create the file <strong>/tmp/dp-mps-10.yaml.</strong> Under the attributesharing.mps.resources in this file, we will define the number of replicas than can be specified for that resource type. These replicas represent the number of applications (pods) that are allowed by the GPU to have shared simultaneous accesses . In the example we are using 10 replicas:</p><pre>cat &lt;&lt; EOF &gt; /tmp/dp-mps-10.yaml<br>version: v1<br>sharing:<br>  mps:<br>    resources:<br>    - name: nvidia.com/gpu<br>      replicas: 10<br>EOF</pre><p>Now we can install the Kubernetes device plugin with the complete configuration:</p><pre>helm upgrade -i nvdp nvdp/nvidia-device-plugin \<br>    --namespace nvidia-device-plugin \<br>    --create-namespace \<br>    --set gfd.enabled=true \<br>    --set config.default=mps10 \<br>    --set-file config.map.mps10=/tmp/dp-mps-10.yaml \<br>    -f https://github.com/NVIDIA/k8s-device-plugin/blob/v0.17.1/deployments/helm/nvidia-device-plugin/values.yaml<br></pre><p>Once the deployment is successfully rolled out, you will notice that in the new<strong> namespace nvidia-device-plugin</strong> different Nvidia applications are supposed to be running:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QaT4c4UQ-tl_nmjSqQgkwg.png" /></figure><p>Lets describe our GPU-based worker node and pay attention to some interesting information:</p><pre>kubectl describe node nodename<br></pre><p>On the <strong>labels</strong> we can confirm our <strong>gpu count</strong> and the <strong>sharing strategy</strong>:</p><pre>nvidia.com/gpu.count=1<br>nvidia.com/gpu.sharing-strategy=mps<br></pre><p>but the available capacity report tell us a different story and on <strong>nvidia.com/gpu</strong> we see now <strong>10</strong> instead of 1. MPS is working:</p><pre>Capacity:<br>  cpu:                30<br>  ephemeral-storage:  148672300Ki<br>  hugepages-1Gi:      0<br>  hugepages-2Mi:      0<br>  memory:             246869828Ki<br>  nvidia.com/gpu:     10<br>  pods:               110<br>Allocatable:<br>  cpu:                29748m<br>  ephemeral-storage:  137016391454<br>  hugepages-1Gi:      0<br>  hugepages-2Mi:      0<br>  memory:             235130692Ki<br>  nvidia.com/gpu:     10<br>  pods:               110</pre><p>We are ready to run some tests.</p><p>For a first testing apply the following deployment example, to see 10 replicas of the pod-gpu-deploy pod claiming simultaneously for GPU resources:</p><pre>#pod-gpu-deploy.yaml <br>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  labels:<br>    app: pod-gpu-deploy<br>  name: pod-gpu-deploy<br>spec:<br>  replicas: 10<br>  selector:<br>    matchLabels:<br>      app: pod-gpu-deploy<br>  template:<br>    metadata:<br>      labels:<br>        app: pod-gpu-deploy<br>    spec:    <br>      containers:<br>      - image: k8s.gcr.io/cuda-vector-add:v0.1<br>        name: cuda-vector-add<br>        resources:<br>          limits:<br>            nvidia.com/gpu: 1</pre><p>For a second and final testing, run the following Kubernetes job:</p><pre>apiVersion: batch/v1<br>  kind: Job<br>  metadata:<br>    name: nbody-sample<br>  spec:<br>    completions: 3<br>    parallelism: 3<br>    template:<br>      spec:<br>        hostIPC: true<br>        containers:<br>          - name: nbody-sample<br>            image: nvidia/samples:nbody<br>            command: [&quot;/tmp/nbody&quot;]<br>            args: [&quot;-benchmark&quot;, &quot;-i=5000&quot;]<br>            resources:<br>              limits:<br>                nvidia.com/gpu: 1<br>        restartPolicy: &quot;Never&quot;<br>    backoffLimit: 1</pre><p>You should be able to check the logs of the 3 pods created by the job and validate they were trying to access the GPU at the same time.</p><p>This is a fairly straightforward technical exercise. Great to validate a possible solution for the GPU sharing challenges you might have on your organization.</p><p>However, as Nvidia puts it very clear in the documentation, there are different types of GPU sharing approaches for a reason. Different scenarios and different workloads might imply different GPU sharing strategies. Keep that in mind.</p><p>Let us know if you find any incongruences regarding the exercise, we would love to hear from you.</p><p>Hope it helps!</p><p>PS: Thanks to <a href="https://medium.com/u/92466005872f">Oguz Pastirmaci</a> for <a href="https://github.com/OguzPastirmaci/misc/tree/master/oke-mps/ol">his insights regarding MPS</a>.</p><ul><li><a href="https://github.com/NVIDIA/k8s-device-plugin?tab=readme-ov-file#with-cuda-mps">GitHub - NVIDIA/k8s-device-plugin: NVIDIA device plugin for Kubernetes</a></li><li><a href="https://github.com/NVIDIA/k8s-device-plugin?tab=readme-ov-file#deployment-via-helm">GitHub - NVIDIA/k8s-device-plugin: NVIDIA device plugin for Kubernetes</a></li><li><a href="https://github.com/OguzPastirmaci/misc/tree/master/oke-mps/ol">misc/oke-mps/ol at master · OguzPastirmaci/misc</a></li><li><a href="https://blogs.oracle.com/developers/post/streamlining-gpu-management-on-oci-kubernetes-engine-oke-with-the-nvidia-gpu-operator">Streamlining GPU Management on OCI Kubernetes Engine (OKE) with the Nvidia GPU Operator</a></li><li><a href="https://blogs.nvidia.com/blog/whats-the-difference-between-a-cpu-and-a-gpu/">CPU vs GPU: What&#39;s the difference?</a></li><li><a href="https://github.com/NVIDIA/k8s-device-plugin">GitHub - NVIDIA/k8s-device-plugin: NVIDIA device plugin for Kubernetes</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=882048ed364e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oracledevs/gpu-sharing-with-mps-and-oke-882048ed364e">GPU sharing with MPS and OKE</a> was originally published in <a href="https://medium.com/oracledevs">Oracle Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ceph in OKE with Rook and PVCs]]></title>
            <link>https://medium.com/oracledevs/ceph-in-oke-with-rook-and-pvcs-2f5724458d9f?source=rss-b6254430356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/2f5724458d9f</guid>
            <category><![CDATA[storage]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[ceph]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[rook]]></category>
            <dc:creator><![CDATA[Fernando Harris]]></dc:creator>
            <pubDate>Wed, 05 Mar 2025 15:46:25 GMT</pubDate>
            <atom:updated>2025-03-05T15:46:25.914Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*rcCE6kGMsffp2nc2" /><figcaption>Photo by <a href="https://unsplash.com/@live_for_photo?utm_source=medium&amp;utm_medium=referral">Teng Yuhong</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Introduction</h3><p>Application persistency is a very important challenge in cloud native where very frequently applications tend to be stateless. Exceptions to this “rule” are typical critical applications, such as cache or databases, and managing this type of requirement inside Kubernetes can bring a bit more effort to developers and operations.</p><p>In this blog entry, we will show you very quickly how to use Rook to manage the lifecycle of a Ceph cluster in OKE and let our applications claim for storage automatically with PVCs through the OCI Block Volume (oci-bv) storage class.</p><p>This exercise complements the previous works from <a href="https://medium.com/u/2ab4f5d23a9a">Gilson Melo</a> <a href="https://blogs.oracle.com/cloud-infrastructure/post/running-ceph-clusters-with-rook-in-oracle-container-engine-for-kubernetes">here</a> and <a href="https://medium.com/u/65589502497">Deepak Devadathan</a> <a href="https://medium.com/@xsgdkh/rook-cloud-native-storage-orchestrator-deployment-in-oke-f0f0e0346f67">here</a> where both make a detailed review of Ceph, Rook and OKE based on host storage.</p><h3>Ceph Clusters</h3><p>Ceph is an open-source, reliable distributed storage system with great scalability, that abstracts infrastructure, allowing clients to consume object, block, and file storage, transparently and efficiently, without losing performance, and guaranteeing low latencies and high-availability.</p><p><strong>Reliability</strong> and <strong>business continuity</strong> are key terms in this discussion. And in this case, using and abstracting OCI storage infrastructure can be of great value for the business. As a distributed system, when associate it with OCI Availability Domains (AD’s) to distribute node locations across different zones, Ceph increases the organisation capacity to guarantee business continuity and reduce operational risk.</p><p>A generic utilisation of Ceph with OCI can be found <a href="https://medium.com/oracledevs/using-ceph-distributed-storage-cluster-on-bare-metal-cloud-services-8738b9070410">here</a>.</p><h3>Where Rook comes in!</h3><p>As more and more users adopt cloud native platforms like Kubernetes with all its operational predicates and benefits, there is also an increasing interest on adopting technologies like Ceph within a cloud native environment. Running Ceph implies some preparation work and that preparation work can be even more challenging if we want to run Ceph inside Kubernetes.</p><p>If we want to use Ceph with Kubernetes and tackle — at least — part of the operational complexity, we can use Rook. Rook uses an operator to simplify our tasks and help us automate the management of the lifecycle of Ceph resources in Kubernetes. You can install it manually or with helm.</p><h3>Ceph storage types</h3><p>A Ceph storage cluster configuration can be based on <strong>4 different local storage types</strong>:</p><ul><li>Raw devices</li><li>Raw partitions</li><li>LVM Logical Volumes</li><li>Persistent Volumes</li></ul><p>The first 3 options will store data directly on the host. For that a host storage cluster is provisioned and configured, where Ceph OSDs will be raw devices (OCI <em>paravirtualized</em> Block Volumes attached to the worker node vm) with no partitions or formatted filesystems and Ceph Mons will be storing the metadata at a specific path on the host as explained <a href="https://rook.io/docs/rook/latest-release/CRDs/Cluster/host-cluster/">here</a>. Thats exactly what the other 2 examples I cited did: <a href="https://blogs.oracle.com/cloud-infrastructure/post/running-ceph-clusters-with-rook-in-oracle-container-engine-for-kubernetes">here</a> and <a href="https://medium.com/@xsgdkh/rook-cloud-native-storage-orchestrator-deployment-in-oke-f0f0e0346f67">here</a></p><p>The fourth option is the one we are going to try here today. <strong>We need to have Persistent Volumes available from a storage class in block mode</strong>. In this case, ceph-block storage classes will abstract and dynamically consume OCI Block Volume through the <strong>oci-bv Kubernetes storage class</strong>.</p><p>For the example, a Kubernetes cluster with at least 3 worker nodes is needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dXz0B1d_D8lrTa66TkhlUQ.png" /><figcaption>Our cluster runs Kubernetes version v1.30.1 in Frankfurt</figcaption></figure><p>As I write this the Kubernetes versions supported by Rook are <strong>v1.27</strong> to <strong>v1.32.</strong> I will reuse an OKE cluster I provisioned previously with 5 nodes and Kubernetes <strong>v1.30.1.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*ZH1gCKxiBRh1LK3hd_VU5g.png" /></figure><p>See the documentation for more details on storage settings available and explore the example in Github <a href="https://github.com/rook/rook/blob/master/deploy/examples/cluster-on-pvc.yaml">here</a>.</p><p>You will need to install the following manifests before creating the cluster:</p><p><a href="https://raw.githubusercontent.com/rook/rook/refs/heads/master/deploy/examples/crds.yaml">crds.yaml</a><br><a href="https://raw.githubusercontent.com/rook/rook/refs/heads/master/deploy/examples/common.yaml">common.yaml</a><br><a href="https://raw.githubusercontent.com/rook/rook/refs/heads/master/deploy/examples/operator.yaml">operator.yaml</a></p><pre>kubectl create -f crds.yaml </pre><pre>kubectl create -f common.yaml </pre><pre>kubectl create -f operator.yaml</pre><p>Once that’s done, check the status of the Rook operator:</p><pre>kubectl -n rook-ceph get pods rook-ceph-operator-5d474fdcfd-w5t7r</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mubD2M7z2VJ9Ud00vxFvmw.png" /></figure><p>If its running then we can start provisioning the ceph cluster. I’m sharing below my configuration, which is based on the <a href="https://github.com/rook/rook/blob/master/deploy/examples/cluster-on-pvc.yaml">official example:</a></p><pre>#cluster-on-pvc.yaml<br><br>apiVersion: ceph.rook.io/v1<br>kind: CephCluster<br>metadata:<br>  name: rook-ceph<br>  namespace: rook-ceph # namespace:cluster<br>spec:<br>  dataDirHostPath: /var/lib/rook<br>  mon:<br>    count: 3<br>    allowMultiplePerNode: false<br>    volumeClaimTemplate:<br>      spec:<br>        storageClassName: oci-bv<br>        resources:<br>          requests:<br>            storage: 20Gi<br>  cephVersion:<br>    image: quay.io/ceph/ceph:v19.2.0<br>    allowUnsupported: false<br>  skipUpgradeChecks: false<br>  continueUpgradeAfterChecksEvenIfNotHealthy: false<br>  mgr:<br>    count: 2<br>    allowMultiplePerNode: false<br>    modules:<br>      - name: rook<br>        enabled: true<br>  dashboard:<br>    enabled: true<br>    ssl: true<br>  crashCollector:<br>    disable: false<br>  logCollector:<br>    enabled: true<br>    periodicity: daily # one of: hourly, daily, weekly, monthly<br>    maxLogSize: 500M # SUFFIX may be &#39;M&#39; or &#39;G&#39;. Must be at least 1M.<br>  storage:<br>    allowDeviceClassUpdate: false # whether to allow changing the device class of an OSD after it is created<br>    allowOsdCrushWeightUpdate: true # whether to allow resizing the OSD crush weight after osd pvc is increased<br>    storageClassDeviceSets:<br>      - name: set1<br>        # The number of OSDs to create from this device set<br>        count: 3<br>        portable: true<br>        tuneDeviceClass: true<br>        tuneFastDeviceClass: false<br>        encrypted: false<br>        placement:<br>          topologySpreadConstraints:<br>            - maxSkew: 1<br>              topologyKey: kubernetes.io/hostname<br>              whenUnsatisfiable: ScheduleAnyway<br>              labelSelector:<br>                matchExpressions:<br>                  - key: app<br>                    operator: In<br>                    values:<br>                      - rook-ceph-osd<br>        preparePlacement:<br>          podAntiAffinity:<br>            preferredDuringSchedulingIgnoredDuringExecution:<br>              - weight: 100<br>                podAffinityTerm:<br>                  labelSelector:<br>                    matchExpressions:<br>                      - key: app<br>                        operator: In<br>                        values:<br>                          - rook-ceph-osd<br>                      - key: app<br>                        operator: In<br>                        values:<br>                          - rook-ceph-osd-prepare<br>                  topologyKey: kubernetes.io/hostname<br>          topologySpreadConstraints:<br>            - maxSkew: 1<br>              # IMPORTANT: If you don&#39;t have zone labels, change this to another key such as kubernetes.io/hostname<br>              topologyKey: topology.kubernetes.io/zone<br>              whenUnsatisfiable: DoNotSchedule<br>              labelSelector:<br>                matchExpressions:<br>                  - key: app<br>                    operator: In<br>                    values:<br>                      - rook-ceph-osd-prepare<br>        resources:<br>        volumeClaimTemplates:<br>          - metadata:<br>              name: data<br>            spec:<br>              resources:<br>                requests:<br>                  storage: 20Gi<br>              # IMPORTANT: Change the storage class depending on your environment<br>              storageClassName: oci-bv<br>              volumeMode: Block<br>              accessModes:<br>                - ReadWriteOnce<br>    # when onlyApplyOSDPlacement is false, will merge both placement.All() and storageClassDeviceSets.Placement.<br>    onlyApplyOSDPlacement: false<br>  resources:<br>  priorityClassNames:<br>    mon: system-node-critical<br>    osd: system-node-critical<br>    mgr: system-cluster-critical<br>  disruptionManagement:<br>    managePodBudgets: true<br>    osdMaintenanceTimeout: 30<br>    pgHealthCheckTimeout: 0</pre><p>Run:</p><pre>kubectl create -f cluster-on-pvc.yaml</pre><p>You will have to wait a few minutes until all resources and the Ceph cluster gets created. You can check its status with the following command:</p><pre>kubectl -n rook-ceph get cephcluster</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FP2mRCh24l00nGlsjlumHA.png" /></figure><p>Optionally, you can also install the <a href="https://raw.githubusercontent.com/rook/rook/refs/heads/master/deploy/examples/toolbox.yaml">rook-ceph-tools application</a>, if you need more information about the cluster or troubleshooting it, or even directly changing things on it.</p><pre>kubectl create -f toolbox.yaml</pre><p>Once the toolbox pod is deployed, you can use it to interact directly with the Ceph Cluster :</p><pre>kubectl -n rook-ceph exec -it rook-ceph-tools-854954b685-wlsrc -- ceph status</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7wes_hGUgOWDAyyqaeu27w.png" /></figure><p>Now, check all the pods created in the ceph-rook namespace. They should be running, or completed:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*FurgunXPEanGQEo9vGUIOQ.png" /></figure><p>If you have errors, check the logs of the pod in error or the operator pod. For instance, if some pod is pending, maybe the cluster is not being able to schedule it because it has no resources (eg: CPU or memory) available on the worker nodes. If everything is OK, then we can proceed to create the <strong>ceph block pool</strong> and <strong>storage class</strong>.</p><p>Use the files below as a reference for both. Check the <a href="https://github.com/rook/rook/blob/master/deploy/charts/rook-ceph-cluster/values.yaml">documentation</a> if you have doubts:</p><pre>#cephblockpool.yaml<br><br>apiVersion: ceph.rook.io/v1<br>kind: CephBlockPool<br>metadata:<br>  name: replicapool<br>  namespace: rook-ceph<br>spec:<br>  failureDomain: host<br>  replicated:<br>    size: 3</pre><pre># cephstorageclass.yaml<br><br>apiVersion: storage.k8s.io/v1<br>kind: StorageClass<br>metadata:<br>   name: rook-ceph-block<br># Change &quot;rook-ceph&quot; provisioner prefix to match the operator namespace if needed<br>provisioner: rook-ceph.rbd.csi.ceph.com<br>parameters:<br>    # clusterID is the namespace where the rook cluster is running<br>    clusterID: rook-ceph<br>    # Ceph pool into which the RBD image shall be created<br>    pool: replicapool<br><br>    # RBD image format. Defaults to &quot;2&quot;.<br>    imageFormat: &quot;2&quot;<br><br>    # RBD image features. Available for imageFormat: &quot;2&quot;. CSI RBD currently supports only `layering` feature.<br>    imageFeatures: layering<br><br>    # The secrets contain Ceph admin credentials.<br>    csi.storage.k8s.io/provisioner-secret-name: rook-csi-rbd-provisioner<br>    csi.storage.k8s.io/provisioner-secret-namespace: rook-ceph<br>    csi.storage.k8s.io/node-stage-secret-name: rook-csi-rbd-node<br>    csi.storage.k8s.io/node-stage-secret-namespace: rook-ceph<br><br>    # Specify the filesystem type of the volume. If not specified, csi-provisioner<br>    # will set default as `ext4`.<br>    csi.storage.k8s.io/fstype: xfs<br><br># Delete the rbd volume when a PVC is deleted</pre><p>run:</p><pre>kubectl create -f cephblockpool.yaml</pre><pre>kubectl create -f cephstorageclass.yaml</pre><p>Check the storages classes you have now available in your cluster:</p><pre>kubectl get sc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dU-oNqzVHFym4ht9niMSlA.png" /><figcaption>rook-ceph-block storage class created in the cluster</figcaption></figure><p>Finally, lets deploy a stateful MySQL pod from the <a href="https://github.com/rook/rook/blob/master/deploy/examples/mysql.yaml">official example</a>:</p><pre>kubectl apply -f mysql.yaml</pre><p>Check if its mysql claim for persistent volume is successfully bound:</p><pre>kubectl get pvc</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sdcQt2dI3VfbUtY6wXe25g.png" /><figcaption>msql pvc bound with rook-ceph-block storage class</figcaption></figure><p>And now, lets simply inspect the running mysql pod to confirm that the pvc…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vFxyGY4p95WvYwqm71rKJQ.png" /></figure><p>…was successfully connected to the pod…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hQdwYcsV4QiY3xaVNQcfnw.png" /></figure><p>And that’s it.</p><p>Hope it helps.</p><h3>References:</h3><ul><li><a href="https://ceph.io/en/">Home - Ceph</a></li><li><a href="https://medium.com/@xsgdkh/rook-cloud-native-storage-orchestrator-deployment-in-oke-f0f0e0346f67">Rook- Cloud native storage orchestrator deployment in OKE</a></li><li><a href="https://rook.io/">Rook</a></li><li><a href="https://github.com/rook/rook">GitHub - rook/rook: Storage Orchestration for Kubernetes</a></li><li><a href="https://rook.github.io/docs/rook/latest-release/Getting-Started/Prerequisites/prerequisites/">Prerequisites</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2f5724458d9f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oracledevs/ceph-in-oke-with-rook-and-pvcs-2f5724458d9f">Ceph in OKE with Rook and PVCs</a> was originally published in <a href="https://medium.com/oracledevs">Oracle Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Authentication with OAuth2-Proxy, Kubernetes and OCI]]></title>
            <link>https://medium.com/oracledevs/authentication-with-oauth2-proxy-kubernetes-and-oci-6c8d87769184?source=rss-b6254430356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/6c8d87769184</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[oauth2]]></category>
            <category><![CDATA[oauth2-proxy]]></category>
            <category><![CDATA[nginx-ingress-controller]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <dc:creator><![CDATA[Fernando Harris]]></dc:creator>
            <pubDate>Mon, 15 Jul 2024 19:36:38 GMT</pubDate>
            <atom:updated>2024-07-15T19:36:38.263Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*XyafU4TlK6qq1RtF" /><figcaption>Photo by <a href="https://unsplash.com/@titteeparichad?utm_source=medium&amp;utm_medium=referral">Tittee Parichad</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Sometimes we must expose our applications running on Kubernetes to the outside world. Still, many of these applications don’t have the proper mechanisms to manage Authentication and Authorization by themselves. This may be because they are legacy and their code is not maintained anymore or because the developer didn&#39;t initially have that requirement. This problem is real, and we must know what solutions we can use.</p><p>In Oracle Cloud Infrastructure (OCI), a possible solution for this type of problem consists of using <a href="https://www.oracle.com/technical-resources/articles/middleware/oracle-identity-cloud-service.html"><strong>OCI Identity Cloud Services</strong></a> and <a href="https://docs.oracle.com/en-us/iaas/Content/APIGateway/Concepts/apigatewayoverview.htm"><strong>OCI API Gateway</strong></a><strong>, </strong>as seen in these two blog entries <a href="https://blogs.oracle.com/coretec/post/oci-api-gateway-and-openid-connect-authentication-with-iam-domain-idcs-and-azure-btoc">here</a> and <a href="https://www.ateam-oracle.com/post/oidc-oci-api-gateway">here</a>. A more <strong>cloud-native</strong> approach can be done with the <a href="https://github.com/oauth2-proxy/oauth2-proxy"><strong>OAuth2-Proxy</strong></a>. In this case, we will use OAuth2-Proxy as a reverse proxy to manage the OAuth2 authentication flow between OCI with OpenID Connect, the user, and a backend application to validate user accounts by email, domains, or groups. <a href="https://github.com/oauth2-proxy/oauth2-proxy"><strong>OAuth2-Proxy</strong></a><strong> will be deployed in Kubernetes as a pod and coordinate its actions with the </strong><a href="https://docs.nginx.com/nginx-ingress-controller/"><strong>Nginx Ingress Controller</strong></a><strong>.</strong></p><p>As you know <a href="https://oauth.net/2/"><strong>OAuth 2.0</strong></a> is an industry-standard protocol for authorization and Oauth2-Proxy makes straightforward use of it.</p><p>In our example, our backend application is a SpringBoot dummy app running on <a href="https://www.oracle.com/cloud/cloud-native/container-engine-kubernetes/"><strong>Oracle Container Engine for Kubernetes (OKE)</strong></a>.</p><p>The following diagram explains the authentication flow with OAuth2 and <a href="https://openid.net/"><strong>OpenID Connect</strong></a>. OpenID Connect is an extension to the OAuth 2.0 protocol that adds an authentication and identity layer. You can learn more about this and OCI <a href="https://docs.public.oneportal.content.oci.oraclecloud.com/en-us/iaas/Content/Identity/api-getstarted/usingopenidconnect.htm">here</a>.</p><p>The diagram below represents this flow of authentication:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FBPgdwRQ1nukUAyX5kukSw.png" /></figure><p>and can be functionally described in the following manner:</p><ol><li>The user browses the DNS associated with a public Load Balancer with the respective TLS certificate configured with the Nginx ingress controller.</li><li>The request is internally forwarded to OAuth2-Proxy to check the existence of the client token through an ingress rule.</li><li>If the user is not authenticated, the token is absent, and OAuth2-Proxy sends an OAuth2/OpenID Connect-based request to OCI Identity Services.</li><li>Once the user gets authenticated, OAuth2-Proxy can safely route with the help of another nginx ingress configuration, the request to the backend or upstream application.</li></ol><p>Let us now see the configuration of the different building blocks:</p><h3>OCI Identity Services and OpenID Connect</h3><p>As the following image illustrates, we have configured a simple IDCS Confidential Application as a client. For this exercise, there is <strong>no need</strong> to configure any <strong>Resources</strong>. If you want to enforce specific users and groups you will need to enable the flag for the option <strong>Enforce grants as authorization. </strong>The values to retain are the <strong>Client ID, </strong>and the <strong>Client secret </strong>in the<strong> General Information </strong>section<strong>. W</strong>e have also enabled the following<strong> Grant Types</strong>: <strong>Client credentials</strong>, <strong>Refresh Token</strong> and <strong>Authorization code</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EH-nMELnHgn0qNN5qaLsYA.png" /><figcaption>IDCS Confidential Application Client Configuration</figcaption></figure><h3>OCI Container Engine, OKE</h3><p>Download the code from GitHub <a href="https://github.com/fharris/oauth2-proxy-demo">here</a>.</p><p><strong>Deployments and services</strong></p><p>To install the backend application run the following command:</p><pre>kubectl apply -f backend-upstream-app/app-deploy.yaml</pre><p>Now, before deploying OAuth2-Proxy Take a minute to check the configuration in the deployment file here:</p><pre>(...)<br>- args:<br>        - --provider=oidc<br>        - --oidc-issuer-url=https://idcs-xxxxxxxxxxxxxxxxxxxxx65.identity.oraclecloud.com/<br>        - --insecure-oidc-skip-issuer-verification=true<br>        - --insecure-oidc-allow-unverified-email=true<br>        - --insecure-oidc-skip-nonce=true<br>        - --scope=openid profile email<br>        - --email-domain=*<br>        - --upstream=static://200<br>        - --http-address=0.0.0.0:4180<br>        env:<br>        - name: OAUTH2_PROXY_CLIENT_ID<br>          value: &quot;replace_with_value_created_in_idcs&quot;<br>        - name: OAUTH2_PROXY_CLIENT_SECRET<br>          value: &quot;replace_with_value_created_in_idcs&quot;<br>        - name: OAUTH2_PROXY_COOKIE_SECRET<br>          value: &quot;XayiX2Fgeghhe#20&quot; # (**)<br>(...)</pre><p>Replace clientID and secret for the values you obtained on the IDCS console when creating the confidential app. To generate a <strong>cookie secret</strong> check the documentation <a href="https://oauth2-proxy.github.io/oauth2-proxy/configuration/overview">here</a> or run the following command:(**)</p><pre>dd if=/dev/urandom bs=32 count=1 2&gt;/dev/null | base64 | tr -d -- &#39;\n&#39; | tr -- &#39;+/&#39; &#39;-_&#39; ; echo</pre><p>Once you have replaced the values run the following command:</p><pre>kubectl apply -f oauth2-proxy/oauth2-proxy-deploy.yaml</pre><p><strong>Nginx Ingress Controller</strong></p><p>To install the Nginx Ingress Controller in the cluster run the following script :</p><pre>./install-nginx.sh</pre><p>You should have a new namespace called <strong>ingress-nginx</strong> with new objects created. Take a minute to validate that there is a nginx controller pod running and a Load Balancer with an external IP assigned:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5V8jGlwN1qSLCyPzBTCsvA.png" /></figure><p>We have created for this exercise a <strong>domain</strong> and a <strong>TLS certificate</strong>. To learn more about creating domains in OCI, and how to use the O<a href="https://www.oracle.com/cloud/networking/dns/">CI DNS service</a> for DNS translation of domain names<strong> </strong>to machine-readable IP addresses check the documentation right <a href="https://docs.oracle.com/en-us/iaas/Content/DNS/Concepts/dnszonemanagement.htm">here</a>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ckrv8WKFT7Sf67ThDlw_fw.png" /><figcaption>Zone record and subdomain domain associated with IP address in OCI DNS Service</figcaption></figure><p>We have associated the DNS <strong>testingress.fernando.devrocks.io</strong> with the<strong> public IP</strong> assigned to the <strong>nginx ingress-controlled Load Balancer, </strong>as you can see in the above PrintScreen. To learn more about creating TLS certificates in OCI with the <a href="https://www.oracle.com/security/cloud-security/ssl-tls-certificates/">OCI Certificates services</a> and how to manage them including managing the certificate authorities (CAs), and CA bundles, check the documentation <a href="https://docs.oracle.com/en-us/iaas/Content/certificates/overview.htm">here</a>. None of the services, OCI DNS or OCI Certificates are mandatory. You can use other 3rd party DNS services or TLS certificate services such as <a href="https://letsencrypt.org/">Let’s Encrypt</a>, to accomplish the goal of this post. Before using this DNS in our ingresses we need to create a Kubernetes secret with the certificate. Follow the documentation <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengsettingupingresscontroller.htm">here</a> to ensure you understand the process to hide the secret for the TLS. Run the following command:</p><pre>kubectl -n k8-booster-oauth2 create secret tls testingress-tls-secret /<br>--key private.key --cert certificate.crt</pre><p><strong>Ingress configuration, TLS and routes</strong></p><p>To configure the ingress rules for the OAuth2-Proxy deployment run the following command:</p><pre>kubectl apply -f oauth2-proxy/ingress-resource-tls-oauth2.yaml</pre><p>Take a minute to study the configuration:</p><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  annotations:<br>    kubernetes.io/ingress.class: nginx<br>    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;<br>    nginx.ingress.kubernetes.io/proxy-body-size: &quot;2000m&quot;<br>    nginx.ingress.kubernetes.io/proxy-buffer-size: &quot;32k&quot;<br>    nginx.org/client-max-body-size: &quot;2000m&quot;<br>    nginx.org/proxy-buffer-size: &quot;32k&quot;<br>  name: oauth2-proxy-ingress<br>  namespace: k8-booster-oauth2<br>spec:<br>  tls:<br>  - hosts:<br>    - testingress.fernando.devrocks.io<br>    secretName: testingress-tls-secret<br>  rules:<br>  - host: testingress.fernando.devrocks.io<br>    http:<br>      paths:<br>      - path: /oauth2<br>        pathType: Prefix<br>        backend:<br>          service:<br>            name: oauth2-proxy<br>            port:<br>              number: 4180</pre><p>Besides the typical configuration for the host and the secret, you can spot the specific annotations for the token header manipulation. In this case, they are preparing to receive a bigger token in the header. The only path configured is the <strong>/oauth2</strong> path where the oauth2-proxy pod will be waiting to validate the existence of a token. If the token doesn&#39;t exist, it forces the authentication against a pre-defined identity provider service.</p><p>To configure the ingress rules for the backend application run the following command:</p><pre>kubectl apply -f backend-upstream-app/ingress-resource-tls-app.yaml</pre><p>Take a minute to study the configuration:</p><pre>apiVersion: networking.k8s.io/v1<br>kind: Ingress<br>metadata:<br>  annotations:<br>    kubernetes.io/ingress.class: nginx<br>    nginx.ingress.kubernetes.io/ssl-redirect: &quot;true&quot;<br>    nginx.ingress.kubernetes.io/auth-url: &quot;https://$host/oauth2/auth&quot;<br>    nginx.ingress.kubernetes.io/auth-signin: &quot;https://$host/oauth2/start?rd=$escaped_request_uri&quot;<br>  name: backend-app-ingress<br>  namespace: k8-booster-oauth2<br>spec:<br>  tls:<br>  - hosts:<br>    - testingress.fernando.devrocks.io<br>    secretName: testingress-tls-secret<br>  rules:<br>  - host: testingress.fernando.devrocks.io<br>    http:<br>      paths:<br>      - path: /<br>        pathType: Prefix<br>        backend:<br>          service:<br>            name: cloudnativebasicspring-service<br>            port:<br>              number: 80</pre><p>Again, besides the typical nginx configuration for the host and the secret, you can spot the specific annotations for the <strong>auth-URL</strong> and <strong>auth-signing</strong> path. This means that whenever a request is received it should first be validated by OAuth2-Proxy.</p><h3>Ready to test</h3><p>Open an incognito browser tab and enter your DNS:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CDci-gC5pAX-bqFiFkF19A.png" /></figure><p>There is no active token, so the identity provider is called to authenticate the user:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wFPfC7l3Agu6WzyHeCI13g.png" /></figure><p>Once the user authenticates, it gets access to the backend upstream application:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h6cc4TDl9I-YnZDS3kyVTw.png" /></figure><p>That’s all ;)</p><p>Thank you for reading. I hope it&#39;s helpful.</p><h3>Other references</h3><p>Oauth2-proxy <a href="https://github.com/oauth2-proxy/oauth2-proxy">https://github.com/oauth2-proxy/oauth2-proxy</a></p><ul><li><a href="https://oauth.net/2/">OAuth 2.0 - OAuth</a></li><li><a href="https://medium.com/@aditya.oo7.developer/authentication-authorization-in-kubernetes-oauth2-proxy-with-dex-idp-dda958f92729">Authentication &amp; Authorization in Kubernetes — Oauth2 Proxy with Dex IdP</a></li><li><a href="https://kubernetes.github.io/ingress-nginx/examples/auth/oauth-external-auth/">External OAUTH Authentication - Ingress-Nginx Controller</a></li><li><a href="https://aviitala.com/posts/nginx-ingress-oauth2/">Protecting kubernetes with OAuth2 Proxy and NGINX Ingress</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c8d87769184" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oracledevs/authentication-with-oauth2-proxy-kubernetes-and-oci-6c8d87769184">Authentication with OAuth2-Proxy, Kubernetes and OCI</a> was originally published in <a href="https://medium.com/oracledevs">Oracle Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[OKE Disaster Recovery: Notes on Velero and OKE — part 3: Stateful Pods with Persistent Volumes and…]]></title>
            <link>https://medium.com/oracledevs/oke-disaster-recovery-notes-on-velero-and-oke-part-3-stateful-pods-with-persistent-volumes-and-a6eacef7600b?source=rss-b6254430356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a6eacef7600b</guid>
            <category><![CDATA[velero]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[disaster-recovery]]></category>
            <category><![CDATA[cloud-native]]></category>
            <dc:creator><![CDATA[Fernando Harris]]></dc:creator>
            <pubDate>Fri, 15 Mar 2024 18:05:11 GMT</pubDate>
            <atom:updated>2024-03-15T18:05:11.632Z</atom:updated>
            <content:encoded><![CDATA[<h3>OKE Disaster Recovery: Notes on Velero and OKE — part 3: Stateful Pods with Persistent Volumes and File Storage</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*YStuAVRqlDarkKBQ" /><figcaption>Photo by <a href="https://unsplash.com/@jessedo81?utm_source=medium&amp;utm_medium=referral">jesse orrico</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Welcome to the third and final part of this series. In <a href="https://medium.com/oracledevs/disaster-recovery-notes-on-velero-and-oke-part-1-stateless-pods-b4ba3e737386"><strong>part one</strong></a> we learned how to use Velero for a simple backup of a stateless application running in an OKE Kubernetes cluster in Frankfurt to object storage in Frankfurt, to then restore the application in an OKE Kubernetes cluster in London. The <a href="https://medium.com/oracledevs/disaster-recovery-notes-on-velero-and-oke-part-2-stateful-pods-with-persistent-volumes-and-80204b3ac6d7"><strong>second part</strong></a> took us on a journey to achieve the same results but with a stateful application dependent on Persistent Block Volume. The third part which you are about to read continues with what was done in part two. However, this time, instead of depending on Block Storage, the application will depend on File Storage.</p><p>Before starting to play with File Storage and OKE, we recommend you visit its OCI documentation <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengcreatingpersistentvolumeclaim_Provisioning_PVCs_on_FSS.htm">here</a> and learn about the network configuration and specific policies you might need to set up in advance.</p><p>Let’s start. Confirm that your kubectl client is targeting Frankfurt.</p><pre>kubectl get nodes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*anDbupHycCiZtEwnNwNKEA.png" /></figure><p>The first thing you will need to do is to create a storage class in Region 1, Frankfurt. Create a file called <strong>fss-dyn-storage-frankfurt.yaml</strong> with the manifest below. For simplicity, the File Storage Mount Target will be placed in the same subnet as the worker nodes. Learn more <a href="https://docs.oracle.com/en-us/iaas/Content/File/Tasks/securitylistsfilestorage.htm#scenario-b">here</a>. For that reason, the value in <strong>mountTargetSubnetOcid</strong> contains the id of the Kubernetes cluster worker nodes subnet. For production, check what is recommended <a href="https://docs.oracle.com/en-us/iaas/Content/File/Tasks/securitylistsfilestorage.htm#scenario-a">here</a>.</p><pre>kind: StorageClass<br>apiVersion: storage.k8s.io/v1<br>metadata:<br>  name: fss-dyn-storage<br>provisioner: fss.csi.oraclecloud.com<br>parameters:<br>  availabilityDomain: EU-FRANKFURT-1-AD-3<br>  mountTargetSubnetOcid: ocid1.subnet.oc1.eu-frankfurt-1.aaaaa...<br>  encryptInTransit: &quot;false&quot;</pre><p>Run the following command to create the storage class:</p><pre>kubectl apply -f fss-dyn-storage-frankfurt.yaml</pre><p>Let’s now create a namespace for the exercise:</p><pre>kubectl create ns nginx-fss</pre><p>Once the namespace is created, create the file <strong>fss-dyn-claim.yaml</strong> with the PVC manifest content below:</p><pre>apiVersion: v1<br>kind: PersistentVolumeClaim<br>metadata:<br>  name: fss-dynamic-claim<br>  namespace: nginx-fss<br>spec:<br>  accessModes:<br>    - ReadWriteMany<br>  storageClassName: &quot;fss-dyn-storage&quot;<br>  resources:<br>    requests:<br>      storage: 50Gi</pre><p>Run the command to apply and create it in the namespace nginx-fss:</p><pre>kubectl apply -f fss-dyn-claim.yaml</pre><p>After a few seconds, the result should be a PVC and PV created and bounded. Run the following command to validate that:</p><pre>kubectl get pvc -n nginx-fss</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IFMM_Ip7gBdmn6W72VvF6g.png" /></figure><p>The <strong>fss-dynamic-claim PVC</strong> should be with <strong>Status=Bound</strong> and assigned to a <strong>csi-fss-(…)</strong> volume with the respective fss-dyn-storage storage class. You can also visually confirm that in the OCI File Storage console where you can see the File Storage created, the Mount Target and its respective IP within the worker node subnet:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NQmnwVsNKzwOZrE0zck5IA.png" /></figure><p>Next, let’s create the stateful application with a persistent-storage volume, to be mounted on <em>/usr/share/nginx/html</em>. Create a file called <strong>fss-pod-nginx.yaml </strong>with the pod manifest below:</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: fss-dynamic-app<br>  namespace: nginx-fss<br>spec:<br>  containers:<br>    - name: nginx<br>      image: nginx:latest<br>      ports:<br>        - name: http<br>          containerPort: 80<br>      volumeMounts:<br>        - name: persistent-storage<br>          mountPath: /usr/share/nginx/html<br>  volumes:<br>  - name: persistent-storage<br>    persistentVolumeClaim:<br>      claimName: fss-dynamic-claim</pre><p>Then, run the following command:</p><pre>kubectl apply -f fss-pod-nginx.yaml</pre><p>Wait for the pod to be running without errors:</p><pre>kubectl get pod -n nginx-fss</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OuggOOIcuQBIAUiYpUExyQ.png" /></figure><p>When running, execute the following command to execute a terminal in the fss-dynamic-app pod container:</p><pre>kubectl -n nginx-fss exec -it fss-dynamic-app -- bash</pre><p>Once inside the container run the following command to create a new file called Hello.World inside the folder mounted on the volume:</p><pre>echo &quot;Hello World&quot; &gt; /usr/share/nginx/html/Hello.World;</pre><p>Follow the below image if you have any doubts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XEqHe8W1jvDqunHgr8P5mQ.png" /></figure><p>To prepare the backup we need first to annotate the pod:</p><pre>kubectl -n nginx-fss annotate pod/fss-dynamic-app \<br>backup.velero.io/backup-volumes=persistent-storage</pre><p>Where <strong>persistent-storage</strong> is the name of the volume to backup.</p><p>All set to start backup creation :</p><pre>./velero backup create nginx-backup-fss \<br>--include-namespaces nginx-fss --default-volumes-to-fs-backup</pre><p>Describe the backup to confirm that is completed successfully:</p><pre>./velero backup describe nginx-backup-fss</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HVFp9qTTTdHyiUPhxidtjQ.png" /></figure><p>If you wish, take a look as well at the OCI Object Storage console to visually confirm that the backup was successfully created. You should be able to see a nginx-backup-fss folder inside the folder backups, and the namespace volume data in the folder nginx-fss inside the folder kopia:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l-6J6W1GsTaVBOTmKOw2NQ.png" /></figure><p>The last thing to do in Frankfurt is to copy the object storage structure and content to London (if you have any doubts about this process revisit <a href="https://medium.com/oracledevs/disaster-recovery-notes-on-velero-and-oke-part-1-stateless-pods-b4ba3e737386">part 1</a> of this series):</p><pre>./oci-copy-objects-to-region.sh</pre><p>Work done in Frankfurt, let’s move to London.</p><p>First, please confirm that the Object storage structure from the bucket in Frankfurt was copied to London. You can do this visually by visiting the OCI Object Storage console and checking the existence of the same folders: <strong>backups/nginx-backup-fss</strong> and <strong>kopia/nginx-fss</strong>.</p><p>Then, we need to replicate some of the same steps we did previously in Frankfurt.</p><p>Make sure your kubectl client is pointing to the London OKE cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gkobvBp9nB6YJXIJcoK62A.png" /></figure><p>The first step is to create a File Storage Class in the London cluster. Create a file named <strong>fss-dyn-storage-london.yaml </strong>with the content of the manifest below. You need of course to use the <strong>ID (OCID) </strong>of your worker node subnet:</p><pre>kind: StorageClass<br>apiVersion: storage.k8s.io/v1<br>metadata:<br>  name: fss-dyn-storage<br>provisioner: fss.csi.oraclecloud.com<br>parameters:<br>  availabilityDomain: UK-LONDON-1-AD-1<br>  mountTargetSubnetOcid: ocid1.subnet.oc1.uk-london-1.aaaa...<br>  encryptInTransit: &quot;false&quot;</pre><p>Run the command to create it:</p><pre>kubectl apply -f fss-dyn-storage-london.yaml</pre><p>Now, let&#39;s ask Velero to tell us which backups are available to restore in London:</p><pre>./velero backup get</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Fkds6l-QjJuaZnNEEUWWyg.png" /></figure><p>Of course, the one we are interested in is <strong>nginx-backup-fss</strong>, which we just copied from Frankfurt Object Storage into London Object Storage:</p><p>Let&#39;s try to restore it with the following command:</p><pre>./velero restore create --from-backup nginx-backup-fss</pre><p>Describe it to validate if it was completed:</p><pre>./velero restore describe nginx-backup-fss-20231113120226</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Njw3Zw18JhJPGNjwWX2C6w.png" /></figure><p>Checking the logs and searching for Persistent Volume related information will show that all restoring tasks were completed:</p><pre>./velero restore logs nginx-backup-fss-20231113120226 | grep -in volume</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zbonvz0knBz29Myf_3Tawg.png" /></figure><p>And now, let&#39;s inspect our pod with the following command to prove that the application was restored with its volumes and content as they were created in Frankfurt:</p><pre>kubectl -n nginx-fss exec -it fss-dynamic-app \<br>-- cat /usr/share/nginx/html/Hello.World</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IZnz9crLat-FI6FVtPZjBQ.png" /></figure><p>And that’s it.</p><p>I hope you enjoyed studying Velero as an open-source tool for Kubernetes backups. Velero is a valid option to implement a multi-region disaster recovery strategy for Oracle Container Engine, aka OKE. With it, we can safely back up and migrate Kubernetes cluster objects from one region to another, including persistent volumes based on Block Volume or File Storage, and easily restore a stateless or stateful cloud-native application.</p><h3><strong>References:</strong></h3><ul><li><a href="https://velero.io/">Velero</a></li><li><a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Concepts/contengoverview.htm">Overview of Container Engine for Kubernetes</a></li><li><a href="https://blogs.oracle.com/cloud-infrastructure/post/backing-up-your-oke-environment-with-velero">Velero backup for Oracle Container Engine for Kubernetes</a></li><li><a href="https://github.com/vmware-tanzu/velero/releases">Releases · vmware-tanzu/velero</a></li><li><a href="https://velero.io/docs/v1.12/contributions/oracle-config/">Use Oracle Cloud as a Backup Storage Provider for Velero</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a6eacef7600b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oracledevs/oke-disaster-recovery-notes-on-velero-and-oke-part-3-stateful-pods-with-persistent-volumes-and-a6eacef7600b">OKE Disaster Recovery: Notes on Velero and OKE — part 3: Stateful Pods with Persistent Volumes and…</a> was originally published in <a href="https://medium.com/oracledevs">Oracle Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Disaster Recovery — Notes on Velero and OKE, Part 2: Stateful Pods with Persistent Volumes and…]]></title>
            <link>https://medium.com/oracledevs/disaster-recovery-notes-on-velero-and-oke-part-2-stateful-pods-with-persistent-volumes-and-80204b3ac6d7?source=rss-b6254430356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/80204b3ac6d7</guid>
            <category><![CDATA[business-continuity]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[velero]]></category>
            <category><![CDATA[disaster-recovery]]></category>
            <dc:creator><![CDATA[Fernando Harris]]></dc:creator>
            <pubDate>Tue, 23 Jan 2024 00:43:23 GMT</pubDate>
            <atom:updated>2024-01-23T00:43:23.182Z</atom:updated>
            <content:encoded><![CDATA[<h3>Disaster Recovery — Notes on Velero and OKE, Part 2: Stateful Pods with Persistent Volumes and Block Volume</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*2--HSve-CLlHMztf" /><figcaption>Photo by <a href="https://unsplash.com/@mattpalmer?utm_source=medium&amp;utm_medium=referral">Matt Palmer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>If you are new to <a href="https://velero.io/">Velero</a> and <a href="https://www.oracle.com/cloud/cloud-native/container-engine-kubernetes/">OKE</a>, please visit the first part of this blog <a href="https://medium.com/oracledevs/disaster-recovery-notes-on-velero-and-oke-part-1-stateless-pods-b4ba3e737386">here </a>which explains step-by-step how to set up Velero to back up a stateless application in OKE. It also shows the very basics of Velero.</p><p>We will build from there and repeat the exercise this time with a stateful application that depends on Persistent Volumes and Block Volume. We need to make a small change in our Velero installation. To support Volumes backups, Velero needs to install in the cluster a node agent.</p><p>Confirm your kubectl client is targeting Frankfurt, our Region 1:</p><pre>kubectl get nodes</pre><p>You should be able to see your nodes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DEg1_iueS9pwO-kMDnuGWQ.png" /></figure><p>Now, run the following command to reinstall Velero with the node agent in Region 1 (Frankfurt):</p><pre>./velero install \<br>--provider aws \<br>--bucket bucket-velero \<br>--secret-file ./velero-credentials \<br>--plugins velero/velero-plugin-for-aws:v1.8.0 \<br>--use-volume-snapshots=false \<br>--backup-location-config region=eu-frankfurt-1,s3ForcePathStyle=&quot;true&quot;,\<br>s3Url=https://&lt;&lt;namespace&gt;&gt;.compat.objectstorage.eu-frankfurt-1.oraclecloud.com \<br>--use-node-agent</pre><p>You should have now a daemon set running in the Velero namespace. Run the following command to validate that:</p><pre>kubectl -n velero get daemonset/node-agent</pre><p>The below picture shows that the Velero <strong>node-agent</strong> was successfully installed and is running as expected:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z_EZQsfgBxCnO8A4GVNuuQ.png" /></figure><blockquote>Velero should now be prepared to support the backup of volumes bound to pods.</blockquote><p>Time to prepare our stateful application to backup. First, create the <strong>nginx-bv</strong> namespace with the following command:</p><pre>kubectl create ns nginx-bv</pre><p>Now, create a file called <em>mynginxclaim.yaml </em>with the <strong>mynginxclaim</strong> PVC manifest below:</p><pre>apiVersion: v1<br>kind: PersistentVolumeClaim<br>metadata:<br>  name: mynginxclaim<br>  namespace: nginx-bv<br>spec:<br>  storageClassName: &quot;oci-bv&quot;<br>  accessModes:<br>    - ReadWriteOnce<br>  resources:<br>    requests:<br>      storage: 50Gi</pre><p>Run the following command to create the PVC in the namespace nginx-bv:</p><pre>kubectl apply -f mynginxclaim.yaml</pre><p>The PVC will remain in pending status until our next step which is to deploy a naked nginx pod that creates a volume called <strong>data</strong> with the Persistent Volume Claim <strong>mynginxclaim . </strong>Create a file called<strong> </strong><em>mynginxpod-bv.yaml </em>with the content below:</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: nginx<br>  namespace: nginx-bv<br>spec:<br>  containers:<br>    - name: nginx<br>      image: nginx:latest<br>      ports:<br>        - name: http<br>          containerPort: 80<br>      volumeMounts:<br>        - name: data<br>          mountPath: /usr/share/nginx/html<br>  volumes:<br>    - name: data<br>      persistentVolumeClaim:<br>        claimName: mynginxclaim</pre><p>Run the following command to deploy the pod:</p><pre>kubectl apply -f mynginxpod-bv.yaml</pre><p>Confirm a Persistent Volume was created with the following command:</p><pre>kubectl get pv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z-j4YimTr831qxUsA-_KGg.png" /></figure><p>Or confirm visually in the OCI Console if you prefer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aslEcWQNNqTMoNU6qNLvjw.png" /></figure><p>Check that PVC mynginxclaim status is <strong>bound</strong> and no longer pending with the following command:</p><pre>kubectl -n nginx-bv get pvc </pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VLAd04NaVe_EWnniVBGAzQ.png" /></figure><p>Check that the pod is running without errors and that the volume is well mounted:</p><pre> kubectl -n nginx-bv describe pod nginx</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u_3pKZdAhJpZ9lz_MFvOlQ.png" /><figcaption>mount on /usr/share/nginx/html successful</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*b-bA6zc007mAB1Ie9MWygw.png" /><figcaption>successfully attached volume event</figcaption></figure><p>If everything is OK, please run the following command to create in the nginx pod, inside the nginx container folder in the path <em>/usr/share/nginx/html/</em>, a file called <em>temp.txt</em> containing the text <em>“Hello World”</em>. We expect this file to be persisted in the block volume.</p><pre> <br><br>kubectl -n nginx-bv exec nginx -- bash -c &quot;echo &quot;HelloWorld&quot; &gt; \<br> /usr/share/nginx/html/temp.txt; cat /usr/share/nginx/html/temp.txt;&quot;</pre><p>Next, annotate the <strong>nginx pod</strong> according to Velero documentation <a href="https://velero.io/docs/v1.12/file-system-backup/#using-opt-in-pod-volume-backup">here</a>, with the following command, where <strong>data</strong> is the name of the volume:</p><pre>kubectl -n nginx-bv annotate pod/nginx backup.velero.io/backup-volumes=data</pre><p>Optionally check if the annotation was well created:</p><pre>kubectl -n nginx-bv describe pod nginx | grep -in annotation</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u0pjQClQZvHklAzUvAeNYw.png" /></figure><p>Finally, we are ready to create the Frankfurt backup with Velero:</p><pre>./velero backup create nginx-backup-bv \<br>--include-namespaces nginx-bv \<br>--default-volumes-to-fs-backup</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JDTF6rhry7lbWMy4sIMW3w.png" /></figure><p>You may describe the backup to confirm its creation:</p><pre>./velero backup describe nginx-backup-bv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NC7dotUO8lniov7IJrvjvA.png" /></figure><p>Work is almost done in Frankfurt. We just need to copy the object storage <strong>bucket-velero</strong> from Frankfurt to London (Revisit part 1 of the blog if you have any doubts about this script):</p><pre>./oci-copy-objects-to-region.sh</pre><p>When the copy of the objects in the bucket is finished<strong>, </strong>work is done in Frankfurt and it is time to move to our Region 2, London</p><p><strong>In London:</strong></p><p>The first thing we are going to do is to confirm visually that the object storage copy from Frankfurt from our previous last step was successful:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_tQ-CXpy_vaD_MVmFLK_1w.png" /></figure><p>You can see that we have a nginx-backup-bv folder in the backups main folder and a nginx-bv folder inside a <a href="https://velero.io/docs/v1.10/file-system-backup/#how-velero-integrates-with-kopia">kopia</a> main folder. It looks fine.</p><p>Make sure your kubectl client is now targeting London:</p><pre>kubectl get nodes</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eveAt1smatfF9lz8d13j0g.png" /></figure><p>Next, we will need to reinstall Velero with the node agent in the OKE London cluster as we did in Frankfurt:</p><pre>./velero install \<br>--provider aws \<br>--bucket bucket-velero \<br>--secret-file ./velero-credentials \<br>--plugins velero/velero-plugin-for-aws:v1.8.0 \<br>--use-volume-snapshots=false \<br>--backup-location-config region=uk-london-1,s3ForcePathStyle=&quot;true&quot;,\<br>s3Url=https://&lt;&lt;namespace&gt;&gt;.compat.objectstorage.uk-london-1.oraclecloud.com \<br>--use-node-agent</pre><p>When finished, confirm the node agent is running:</p><pre>kubectl -n velero get daemonset/node-agent</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LtFPJ1A9hL0TD8aGLY83VA.png" /></figure><p>Let&#39;s ask Velero to shows us which backups are available to restore in London:</p><pre>./velero backup get</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*02L5gHfmTb0EVzDjXfuWhg.png" /></figure><p>Thanks to our copy of objects, we can see the backup <strong>nginx-backup </strong>is available. Let’s try to restore it:</p><pre>./velero restore create --from-backup nginx-backup-bv</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gDqfzcOm09-zKF2wx6rkVw.png" /></figure><p>Check the status:</p><pre>./velero restore describe nginx-backup-bv-20231110104118</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zUmc7bpitA2W2KrD8-cOUw.png" /></figure><p>When completed, check the logs if you wish just to confirm that everything went normally and the restore was completed successfully:</p><pre>./velero restore logs nginx-backup-3-20231107140937</pre><p>Let’s validate our application running:</p><pre>kubectl -n nginx-bv get pod</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CvKtF3plk2mfYV8Tov18xQ.png" /></figure><p>Check that PVs and PVC mynginxclaim were created and bound:</p><pre>kubectl get pv;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-tUdeHyux2bt8p4XY9jUdg.png" /></figure><pre>kubectl get pvc -n nginx-bv;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_yHNROYN4tHXc8aJ1KYUfw.png" /></figure><p>Confirm visually in OCI Block Volume console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wb0SfFlijlPIbpLnW1qZNQ.png" /></figure><p>As the nginx pod is finally running in its namespace in London, and all the related assets were successfully recreated, let us test it with the following command to confirm that the previously persisted data in Frankfurt was also restored with the application in London as expected:</p><pre>kubectl -n nginx-bv exec nginx  -it -- cat usr/share/nginx/html/temp.txt</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TLpc_P8biWv410lFs0wbWA.png" /></figure><p>Hurray! You should be reading the “Hello World” from the temp.txt file. This time we’ve used a stateful application that relies on Persistent Block Volume and the exercise was a bit more complex than the first one with the stateless application. The third and final part of this series replicates this exercise with Persistent Volumes and File Storage. See you there.</p><p>References:</p><ul><li><a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengcreatingpersistentvolumeclaim_topic-Provisioning_PVCs_on_BV.htm#Provisioning_Persistent_Volume_Claims_on_the_Block_Volume_Service">Provisioning PVCs on the Block Volume Service</a></li><li><a href="https://velero.io/docs/v1.12/customize-installation/">Customize Velero Install</a></li><li><a href="https://velero.io/docs/v1.12/file-system-backup/#using-opt-in-pod-volume-backup">File System Backup</a></li><li><a href="https://blogs.oracle.com/cloud-infrastructure/post/aks-cluster-migration-to-oke">AKS cluster migration to OKE</a></li></ul><p>Other important references:</p><ul><li><a href="https://docs.oracle.com/en-us/iaas/Content/TrafficManagement/Concepts/overview.htm">Traffic Management</a></li><li><a href="https://docs.oracle.com/en/learn/object-replication-for-dr/index.html#task-2-test-object-storage-cross-region-replication">Configure Object Storage cross-region replication for Disaster Recovery</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=80204b3ac6d7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oracledevs/disaster-recovery-notes-on-velero-and-oke-part-2-stateful-pods-with-persistent-volumes-and-80204b3ac6d7">Disaster Recovery — Notes on Velero and OKE, Part 2: Stateful Pods with Persistent Volumes and…</a> was originally published in <a href="https://medium.com/oracledevs">Oracle Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Disaster Recovery — Notes on Velero and OKE, Part 1: Stateless Pods]]></title>
            <link>https://medium.com/oracledevs/disaster-recovery-notes-on-velero-and-oke-part-1-stateless-pods-b4ba3e737386?source=rss-b6254430356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/b4ba3e737386</guid>
            <category><![CDATA[cloud-native]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[velero]]></category>
            <category><![CDATA[disaster-recovery]]></category>
            <dc:creator><![CDATA[Fernando Harris]]></dc:creator>
            <pubDate>Wed, 15 Nov 2023 17:22:52 GMT</pubDate>
            <atom:updated>2023-11-15T17:22:52.659Z</atom:updated>
            <content:encoded><![CDATA[<h3>Disaster Recovery — Notes on Velero and OKE, Part 1: Stateless Pods</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*s4Audp5cad-KIIeb" /><figcaption>Photo by <a href="https://unsplash.com/@cakirchoff?utm_source=medium&amp;utm_medium=referral">Chad Kirchoff</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>In this blog entry, I am going to share a few personal notes on how to set up Velero for Disaster Recovery with OKE (a.k.a) <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Concepts/contengoverview.htm">Oracle Container Engine</a>, the OCI-managed Kubernetes service.</p><p>The scenario we are recreating is based on a multi-region Disaster Recovery strategy. It&#39;s a conceptual exercise, inheriting some insights from previous blogs shared in the reference, done on a detailed step-by-step approach. We assume you have OCI knowledge, and Kubernetes hands-on experience and have invested some time reading the Velero <a href="https://velero.io/docs/v1.12/">documentation</a>. We are using <strong>velero-v1.12.0-linux-amd64</strong> which you can install from <a href="https://github.com/vmware-tanzu/velero/releases">here</a>.</p><p>For the exercise, we are running 2 Kubernetes (v 1.27) clusters in OCI. The first, aka Region 1, is located in Frankfurt and the second, aka Region 2, is located in London. We are not going to explain here how to do all the needed networking tasks, especially those related to traffic management, including DNS changes to externally target Frankfurt or London. That’s out of scope for now.</p><h3><strong>The objective is simple</strong>: <strong>to back up the application running in Frankfurt and restore it in London</strong>.</h3><p>To achieve our objective the cluster needs to reach Object Storage. That&#39;s how Velero works. The diagram for the operation would be something like the following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P_XhMOzDU8cvhkzRmlxkDA.png" /><figcaption>Velero object storage backup and restore between 2 regions</figcaption></figure><ol><li>The backup from the OKE Frankfurt is persisted to an Object Storage in Frankfurt.</li><li>Once the backup is successfully completed, all data must be explicitly replicated from the Object Storage in Frankfurt to the Object Storage in London.</li><li>Only then, the restoration can be started from the Object Storage in London to the London OKE cluster.</li></ol><p>So, let’s explore in detail what’s needed to accomplish this exercise:</p><p><strong>Step 1) Network pre-configuration</strong></p><p>As mentioned above, OKE will need to reach Object Storage whenever a backup is made or restored. So, make sure that both clusters have in place the ingress and egress rules for their respective regional OCI services. You should at least for the worker nodes subnet have a<strong>n egress rule for All &lt;&lt;Region&gt;&gt; Services in Oracle Services Network, port 443, o</strong>r explicitly create a rule for the O<strong>CI &lt;&lt;Region&gt;&gt; Object storage</strong>. Once the egress rules for the security list are set, create a Service Gateway for the Service you want to reach and the Route Rule targeting the Service Gateway as well. Find the documentation <a href="https://docs.oracle.com/en-us/iaas/Content/Network/Tasks/servicegateway.htm">here</a>.</p><p><strong>Step 2) Creation of the Object Storage buckets</strong></p><p>You will need to create an Object Storage bucket in the root compartment of your tenancy in each region. We are calling it <strong>bucket-velero</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KGZ4bESomnv1RAM3TgohJw.png" /><figcaption>Create in root compartment bucket-velero</figcaption></figure><blockquote>Remember that when you finish this setup in Frankfurt, you will need to replicate steps 1 and 2 in London as well.</blockquote><p><strong>Step 3) Create a Customer Secret Key in OCI</strong></p><p>We are going to use OCI Object Storage S3 compatibility API to support Velero AWS provider installation. The first thing we need to do is to create a secret key. Check the documentation <a href="https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/s3compatibleapi.htm">here</a> and <a href="https://docs.oracle.com/en-us/iaas/Content/Rover/IAM/User_Credentials/Secret_Keys/create_customer-secret-key.htm?source=%3Aow%3Ao%3Abl%3Apo%3A%3A%3A#CreateCustomerSecretKey">here</a> to learn more about the process.</p><p>Basically, in the OCI Console, you will need to go to <strong>Identity-&gt;Users-&gt;User Details</strong> and select <strong>Customer Secret Keys </strong>in <strong>Resources</strong>. Click <strong>Generate Secret Key</strong>. Give it a name and save its values in a safe place. You will need them to create a credentials file to be used by Velero.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kGkCCwT876kCCvvHHWanpA.png" /></figure><p>Once you get the keys you can start playing around with it. <a href="https://github.com/fharris/oci-s3-compatibility">Here</a> you can get a simple Amazon S3 Java Client prepared to test your connection with OCI Object Storage through the compatibility API before installing Velero. You can actually create the bucket with it or simply use it to troubleshoot eventual issues or test your keys.</p><p><strong>Step 4) Velero setup in the Frankfurt cluster (Region 1)</strong></p><p>Confirm you have access to your OKE cluster in Frankfurt:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/630/1*bUZXDsioxLNTOkEKDj_WGA.png" /></figure><p>Create a <strong>velero-crendentials</strong> file with the values created in step 3.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*UqcFCD1ixlu1szr3xautyg.png" /><figcaption>velero-credentials file</figcaption></figure><p>Now let&#39;s run the command to install Velero in the Frankfurt cluster. Please replace <strong>&lt;&lt;objectstoragenamespace&gt;&gt;</strong> with your OCI Object Storage namespace (you can get it from the OCI console):</p><pre>./velero install \<br>--provider aws \<br>--bucket bucket-velero \<br>--secret-file ./velero-credentials \<br>--plugins velero/velero-plugin-for-aws:v1.8.0 \<br>--use-volume-snapshots=false \<br>--backup-location-config region=eu-frankfurt-1,\<br>s3ForcePathStyle=&quot;true&quot;,\<br>s3Url=https://&lt;&lt;objectstoragenamespace&gt;&gt;.compat.objectstorage.eu-frankfurt-1.oraclecloud.com</pre><p>After the installation is complete you can double-check the logs to confirm that all went well :</p><pre>kubectl logs deployment/velero -n velero</pre><p>The below figure presents an extract from the Velero log showing that installation is OK and the <strong>BackupStorageLocation</strong> is <strong>valid</strong> and <strong>available:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZksVwwFKfLe3QC4uaAu0yA.png" /><figcaption>Velero log extract</figcaption></figure><p>We can then validate that the backup location for Velero was indeed well-created and is available with the following command:</p><pre>./velero backup-location get</pre><p>We should get something like the below figure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HeIbKnMZ2pUDqA3CHsUynA.png" /><figcaption>Velero reaches Object Storage from within OKE</figcaption></figure><p><strong>Step 5) Backup a stateless application in Frankfurt — Region 1</strong></p><p>Now that Velero is in place, let&#39;s install the application that we want to back up. Run the following commands to clone the code, and create a namespace, a deployment and a service:</p><pre>git clone https://github.com/fharris/k8cloudbooster;<br><br>kubectl create ns k8-booster;<br><br>kubectl apply -f k8cloudbooster/manifestDeployment.yml;<br><br>kubectl apply -f k8cloudbooster/manifestService.yml; </pre><p>When the service is ready, run the following command to get the load balancer public IP. It might take a few seconds:</p><pre>kubectl get services -n k8-booster;</pre><p>You should see something like the picture below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mB8ydhQnXypMb8kgx0GOCQ.png" /></figure><p>Now, copy-paste the External IP on your browser:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*x-11ZSzSVv4F6mAXH50ByA.png" /></figure><p>And our application is running in Frankfurt.</p><p>Now let&#39;s back it up with Velero with the following command:</p><pre>./velero backup create k8booster-backup --include-namespaces k8-booster</pre><p>We can get the details of the backup by running the following command:</p><pre>./velero backup describe k8booster-backup</pre><p>You should see something like the figure below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/767/1*GooXXdoxIjkdmEn5J3TSmA.png" /></figure><p>And once the backup is completed we can visit the OCI Console to check our Frankfurt Object Storage:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RiEbFNW01ydB8nMSsxsUgg.png" /></figure><p>And confirm that there is in our <strong>bucket-velero</strong> a folder called <strong>backups</strong> containing the <strong>k8booster-backup</strong>.</p><p><strong>Step 5) Object storage replication</strong></p><p>Our work is almost done in Frankfurt. We still need to copy Frankfurt’s <strong>bucket-velero</strong> and its structure to an equivalent bucket in London. There are different ways to do this. In this blog, we’re exploring the option that consists of copying the objects with <a href="https://docs.oracle.com/en-us/iaas/Content/API/Concepts/cliconcepts.htm"><strong>oci cli</strong></a> and the <a href="https://docs.oracle.com/en-us/iaas/api/">OCI API</a>. We have made available for you a script called <strong>oci-copy-objects-to-region.sh </strong>which you can get from<strong> </strong><a href="https://github.com/fharris/myocitools/blob/main/oci-copy-objects-to-region.sh">here</a>. You might need to review the OCI permissions and policies to copy objects from one region to another first. Check the documentation <a href="https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/copyingobjects.htm">here</a> to learn more about that. Alternative ways to do this with OCI Object Storage Replication features can be found in the documentation <a href="https://docs.oracle.com/en/learn/object-replication-for-dr/index.html">here</a> and <a href="https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/usingreplication.htm">here</a>.</p><p>If you go with the script option, please replace the values in <strong>oci-copy-objects-to-region.sh</strong>:</p><pre>#Requirements: oci cli installed and available in PATH<br>#Documentation: https://docs.oracle.com/en-us/iaas/Content/Object/Tasks/copyingobjects.htm <br><br>export SBUCKET=bucket-velero<br>export DBUCKET=bucket-velero<br>export NAMESPACE=&lt;&lt;objectstoragenamespace&gt;&gt;<br>export D_REGION_ID=uk-london-1<br><br># save object store list in a file<br>oci os object list \<br>--bucket-name=$SBUCKET --all | \<br>grep name | awk &#39;{ print $2 }&#39; | sed &#39;s/&quot;//g&#39; | sed &#39;s/,//g&#39; &gt; object.list;<br><br># Bulk objects copy to Destination region:<br>for id in $(cat object.list)<br>do oci os object copy \<br>--bucket-name $SBUCKET \<br>--source-object-name $id \<br>--destination-bucket $DBUCKET \<br>--namespace-name=$NAMESPACE  \<br>--destination-namespace=$NAMESPACE  \<br>--destination-region=$D_REGION_ID<br>done</pre><p>Run the script with the following command:</p><pre>./oci-copy-objects-to-region.sh</pre><p>You should wait and see the <strong>opc-work-request-id</strong> being launched by the script. Something like the figure below :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/656/1*XR2D7OxlmC21vGm_Mdl2kQ.png" /></figure><p>When finished, if you visit your <strong>bucket-velero</strong> in the London Object Storage, the same list of objects and structure should have been replicated successfully. Of course, you can easily automate this script to run periodically as a Kubernetes job, for example.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xYPSB_napzxyfQdRd_TtHw.png" /><figcaption>Objects successfully replicated to London Object Storage bucket- velero</figcaption></figure><p><strong>Step 6) Restoring the stateless application in London — Region 2</strong></p><p>Backup is done. And data was replicated in London. Now we can finally try to restore the application with Velero in the Region 2 cluster in London, but first, we still need to install Velero as we did for Frankfurt. Confirm you have access to your OKE cluster in London:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/601/1*48vjS--J-Rj9DSGRuPuN2Q.png" /></figure><p>The <strong>velero-credentials </strong>file should be the same. All we need is to change the install command to point to London:</p><pre>./velero install \<br>--provider aws \<br>--bucket bucket-velero \<br>--secret-file ./velero-credentials \<br>--plugins velero/velero-plugin-for-aws:v1.8.0 \<br>--use-volume-snapshots=false \<br>--backup-location-config \<br>region=uk-london-1,s3ForcePathStyle=&quot;true&quot;,\<br>s3Url=https://&lt;&lt;namespace&gt;&gt;.compat.objectstorage.uk-london-1.oraclecloud.com</pre><p>Check the Velero pod logs, or validate that you now have an available connection with bucket-velero Object Storage in London.</p><pre>./velero backup-location get</pre><p>If all is good we’ll move and see if there are any available valid backups with the below command:</p><pre>./velero backup get</pre><p>We should be able to see that there is a backup completed and available to restore. The one we just created a few minutes ago in Frankfurt and replicated in London:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sJqBUkprg3ChG6H1QK2yTw.png" /></figure><p>Now, let&#39;s finally try to restore the application in London by running:</p><pre>./velero restore create --from-backup k8booster-backup</pre><p>Check the restore by running the following command:</p><pre>./velero restore describe k8booster-backup-20231030123741</pre><p>The below figure shows the result of this query to Velero:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ptX_hgrWnWFaYCZoATdf4w.png" /></figure><p>Once completed you can also check the logs if you need more information. Let&#39;s test if the restoration went well. A namespace k8-booster, must have been created with its pods and service inside:</p><p>Run:</p><pre>kubectl get all -n k8-booster</pre><p>To see the namespace created and all the objects recreated inside:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*JypnNKsfaA_AmpD5YkpcMw.png" /></figure><p>Check if the service is running by copying pasting the load balancer external IP on your browser. You might need to run first:</p><pre>kubectl -n k8-booster get service</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*zQO74b6bgv9DDTcwmCHFzg.png" /></figure><p>And that’s it.</p><p>This initial exercise was fairly simple because we picked a stateless application. Anyway, the exercise is valid to learn Velero&#39;s basic concepts and how to apply them in OCI. Working with a stateful application brings different challenges as we need to manage as well the Persistent Volumes,(block storage services or file sharing services). We are going to address that complexity in the following blogs. Stay tuned!</p><p>Documentation and references:</p><ul><li><a href="https://velero.io/docs/main/examples/">Examples</a></li><li><a href="https://github.com/vmware-tanzu/velero/releases">Releases · vmware-tanzu/velero</a></li><li><a href="https://velero.io/docs/v1.12/contributions/oracle-config/">Use Oracle Cloud as a Backup Storage Provider for Velero</a></li><li><a href="https://docs.oracle.com/en/learn/aks-eks-to-oke-migration-velero">Migrate your Azure Kubernetes Service Cluster or Amazon EKS Cluster to Container Engine for Kubernetes using Velero</a></li><li><a href="https://blogs.oracle.com/cloud-infrastructure/post/aks-cluster-migration-to-oke">AKS cluster migration to OKE</a></li><li><a href="https://blogs.oracle.com/cloud-infrastructure/post/backing-up-your-oke-environment-with-velero">Velero backup for Oracle Container Engine for Kubernetes</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b4ba3e737386" width="1" height="1" alt=""><hr><p><a href="https://medium.com/oracledevs/disaster-recovery-notes-on-velero-and-oke-part-1-stateless-pods-b4ba3e737386">Disaster Recovery — Notes on Velero and OKE, Part 1: Stateless Pods</a> was originally published in <a href="https://medium.com/oracledevs">Oracle Developers</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A simple async pattern for SpringBoot micro-services with OCI Streaming and Instance Principals]]></title>
            <link>https://medium.com/@HarrisNando/a-simple-async-pattern-for-springboot-micro-services-with-oci-streaming-and-instance-principals-29e7fc2d09cc?source=rss-b6254430356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/29e7fc2d09cc</guid>
            <category><![CDATA[streaming]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <dc:creator><![CDATA[Fernando Harris]]></dc:creator>
            <pubDate>Wed, 16 Feb 2022 14:26:30 GMT</pubDate>
            <atom:updated>2022-02-21T09:28:25.269Z</atom:updated>
            <content:encoded><![CDATA[<h3>Introduction</h3><p>In general terms, asynchronous patterns offer more robust, flexible and loosely coupled architectures. They tend to be more reliable and tolerant because the act of producing and consuming the message will occur asynchronously and rarely simultaneously.By the other hand, complexity can increase, as we start thinking more in terms of events and less in terms of static data living somewhere. This ultimately results in eventual consistent systems, ie, systems that aren’t always consistent, but will eventually be.</p><p>An important tool to implement this type of pattern is a tool which will assume the role of a messaging system. This tool can rely on a highly available cluster or being implemented with a database. You have probably at some point worked or heard about with JMS, Kafka, AQs, MQs. etc.</p><p>These systems tend to be very powerful and used in architectures with important operational requirements, concerning high-availability, scalability, storage durability, throughput, loosely coupled componentes, etc. If you are deciding to use this type of pattern you’ll have to consider that besides the increase in the complexity of the architecture, you will have to deal with specific risks such as lost messages, unordered or duplication of messages, etc.</p><p>Also, if you are considering to use a Message System to provide your architecture with High Availability and Scalability, you should also guarantee that the messaging system itself is scalable and highly available. Duhh.. I know 😐</p><h3>OCI Streaming Service</h3><p>In this regard, the OCI Streaming Service can be an excelente option.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*1s_C9FbdZxt5DQNSmbWmog.png" /><figcaption>OCI Streaming icone</figcaption></figure><p>Being a fully manage service, you will not need to think about managing the service itself, nor its life-cycle, patching, or upgrades. You will not need to think in terms of its scalability or high-availability. Thats is guaranteed by Oracle Cloud Infrastructure with impressive SLAs.</p><p>You just need to create the stream (with the console or with OCI REST API) and start publishing and consuming high-volume data streams.</p><p>On top of that OCI Streaming is compatible with the following Kafka APIs:</p><ul><li><a href="https://kafka.apache.org/documentation/#producerapi">Producer</a> (v0.10.0 and later)</li><li><a href="https://kafka.apache.org/documentation/#consumerapi">Consumer</a> (v0.10.0 and later)</li><li><a href="https://kafka.apache.org/documentation/#connectapi">Connect</a> (v0.10.0.0 and later)</li><li><a href="https://kafka.apache.org/documentation/#adminapi">Admin</a> (v0.10.1.0 and later)</li><li><a href="https://cwiki.apache.org/confluence/display/KAFKA/A+Guide+To+The+Kafka+Protocol">Group Management</a> (v0.10.0 and later)</li></ul><blockquote>This allows you to use applications written for Kafka to send messages to and receive messages from the Streaming service without having to rewrite your code.</blockquote><h3>Create a Stream</h3><p>You can create a Stream with the Console or with the REST API:</p><ol><li><strong>OCI Console</strong>&gt;Analytics &amp; AI&gt;Messaging&gt;Streaming</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FyzBWmnrbKMsTYms0mHz7A.png" /><figcaption><strong>OCI Console</strong>&gt;Analytics &amp; AI&gt;Messaging&gt;Streaming</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MR5Fy3jE0RVPqRnF0ZAgbA.png" /><figcaption>Create Stream</figcaption></figure><p>2. <strong>OCI Rest API</strong>&gt;Post to Create Stream</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vziptqzVndlPJCg9TdfV8Q.png" /><figcaption><strong>OCI Rest API</strong>&gt;Post to Create Stream</figcaption></figure><p>For both, the result is the same:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0LOF2mAIjNrbz-qlkeTTOg.png" /><figcaption>Stream curiosity created successfully</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jl8To4QOL6SxDOn85JXeSQ.png" /><figcaption>Stream curiosity created successfully</figcaption></figure><h3>Explaining the exercise</h3><p>We are going to publish and consume messages against the stream called curiosity we just created. Our end goal is to have 2 spring-boot micro-services. A first service — <strong>curiosityms</strong>- with a publisher role deployed locally in my laptop, and a second -<strong>consumerms</strong>- with a consumer role deployed in an <strong>Oracle Container Engine (aka OKE)</strong> k8s cluster. Both micro-services will have to manage authentication in a slightly different way, since they are actually running in different places.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*Hfw27uhoCra1yueQW3eLSQ.png" /><figcaption>Conceptual Architecture for the exercise</figcaption></figure><h3><strong>The Publisher micro-service</strong></h3><p><strong>Maven Dependencies</strong></p><p>Lets start by declaring the OCI Maven dependencies we will need to develop both the publisher and the consumer:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/540/1*Qm4g7oOAWbm0HBf9p00VHQ.png" /><figcaption>oci java sdk libraries to declare in maven pom file</figcaption></figure><p>As we mentioned, the publisher micro-service will be running locally.</p><p>Let’s say we have a class called <strong>ChampionshipServicePublisher</strong>.</p><p>This class has a simple constructor to prepare the <strong>Stream endpoint </strong>and <strong>id</strong>. The Stream endpoint and its id can be obtained with the REST API or the Console. I’m using OCI REST API in the picture below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QedapDS5sVZmq6a6AfBhuQ.png" /></figure><p>Let’s keep this information in the <strong>application.properties</strong> file as configuration variables which will get their values from a configuration file or environment variables dynamically. This way we guarantee that code is independent from configuration and hence we guarantee <strong>environment parity</strong> between different deployment targets. This would ultimately allow us to use different streams in OCI for different deployments with the same code:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/859/1*_31Vys5oRe4dyhjhfuuRWQ.png" /></figure><p>Our class <strong>ChampionshipServicePublisher</strong> has a simple constructor which dynamically annotates the values from the OCI Streaming configuration in <strong>application.properties</strong> file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3h-bfh3xAm7fiDD0R71qyQ.png" /></figure><p>We also created a method called <strong>prepareOCICall()</strong> which will manage OCI authentication and return a <strong>StreamClient</strong>. Since we are building this service on my laptop, I will use my personal OCI configuration file and API Key — both kept locally — to authenticate against Oracle Cloud Infrastructure:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vmlCvJJggDUPmbk9A7my3A.png" /></figure><p>The OCI config file will make a direct reference to my personal PEM key and is by default located at: <strong>~/.oci/config</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vjOS29JSpzEdJBHL7UhnLw.png" /><figcaption>oci config file and your PEM file location: keep this in a safe place</figcaption></figure><p>Tackled the authentication challenge and we can basically start producing messages. Method <strong>publishMessageToStream()</strong> gets that responsibility:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/994/1*eQHHbndMRq-Z0FgSgU9zNA.png" /></figure><p>This method does 3 things:</p><ol><li>calls the authentication process with a call to <strong>prepareOCICall()</strong>,</li><li>gets and prepares the event which will be published to the Stream</li><li>and finally publishes to the stream.</li></ol><p>Let’s compile and run the code. Our micro-service will be running at localhost port 8090:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aIhrhtEEkRIkTRUgymQTQA.png" /><figcaption>Note the environment variables being passed before running the java -jar ./target/*jar</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IrUgkFK80CBWRZewjrhV0w.png" /><figcaption>Test it with PostMan or curl <a href="http://localhost:8090/wiki/curiosity/page/Fernando/Portugal/Spain">http://localhost:8090/wiki/curiosity/page/Fernando/Portugal/Spain</a></figcaption></figure><p>Executing 3 requests will produce 3 messages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*nWGKX527zuRlSVZlgLdP3w.png" /><figcaption>app logs</figcaption></figure><p>Check OCI Streaming console or REST API to confirm that the messages were published successfully:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L3kq_8NiyePI1PcB5cnDSA.png" /><figcaption>messages were published successfully</figcaption></figure><h3>The Consumer micro-service authentication process</h3><p>The consumerms micro-service will assume the role of a subscriber and will be running in OKE in Oracle Cloud. This means that its authentication process can be slightly different.</p><p>As you noticed, when running locally, we can use a local OCI config file and a local PEM key to get authenticated and eventually publish the messages.</p><p>If we follow a similar approach, and since we are going to run our service in Kubernetes, we would need to “emulate” that situation within a container. Basically the container running our service would need to have a OCI config file and respective PEM key. Well, needless to say that this is not recommendable.</p><p>The best-practice is to use OCI Instance Principals and Dynamic Groups.</p><blockquote>Dynamic groups allow you to group Oracle Cloud Infrastructure compute instances as “principal” actors (similar to user groups). You can then create policies to permit instances to <a href="https://docs.oracle.com/en-us/iaas/Content/Identity/Tasks/callingservicesfrominstances.htm#Calling_Services_from_an_Instance">make API calls against Oracle Cloud Infrastructure services</a>. When you create a dynamic group, rather than adding members explicitly to the group, you instead define a set of <em>matching rules</em> to define the group members. For example, a rule could specify that all instances in a particular compartment are members of the dynamic group. The members can change dynamically as instances are launched and terminated in that compartment.</blockquote><p>Instance principals will let you run compute instances with secure identities and being managed as a proper principal type in Oracle Identity and Access Management. With this type of approach you don’t have to “transport” and “rotate” your credentials. It’s much safer and efficient. Lets see how to do that for the OCI Streaming and Kubernetes:</p><h3>Creating a Dynamic Group</h3><p>In the OCI Console go to:</p><p><strong>Identity &amp; Security &gt; Dynamic Groups</strong></p><p>Click Create Dynamic Group:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/583/1*-rMdLeXnRG3J7nVp0lRLZg.png" /><figcaption>Identity &amp; Security &gt; Dynamic Groups</figcaption></figure><p>And declare the Matching Rules to dynamically include in this group specific instances.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lXMWBD9kc5Voj8dvDKddDA.png" /><figcaption>declare the Matching Rules</figcaption></figure><p>In natural language, I’m simply saying that <strong>all instances belonging to the logical compartment where my Kubernetes Cluster is should be included in this Dynamic Group. </strong>This is handy if I need to create new worker nodes on my k8s cluster. But we could actually be more precise, and instead of declaring a rule impacting over all compartment, simply identify the specific compute instances we want to get included. Both approaches would work for this example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/858/1*e-nCUzj22gthAEoqgnh_qA.png" /><figcaption>rule statement</figcaption></figure><p>Once again, whatever your OCI user is allowed to do with the console, you should be able to do it with the REST API, including creating Dynamic Groups and respective rules:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S33TMfdJWwRQiqIQHNS4Rw.png" /><figcaption>creating Dynamic Groups with OCI Rest APIs</figcaption></figure><h3>Create Policies to Allow the Dynamic Group to have access to Streams in a specific Compartment</h3><p>Now that we have a Dynamic Group we have to declare what the members of this Dynamic Group are allowed to do. And we achieve that with Policies:</p><p>In the Console, go to</p><p>Identity &amp; Security &gt; Policies</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/614/1*Rm8u20Gy7opk7Q3cM3Ez9w.png" /><figcaption>Identity &amp; Security &gt; Policies</figcaption></figure><p>Make sure you are working on the right compartment and click Create Policy. Next , create the statements:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-xC7u1TERLPji-_m1jid5w.png" /><figcaption>create the policy statements</figcaption></figure><p>Declare the policies needed to give access to Streams to the member of the Dynamic Group:</p><p><em>Allow dynamic-group emea-oke-dynamic-group to manage streams in compartment fernando.harris</em></p><p><em>Allow dynamic-group emea-oke-dynamic-group to manage stream-family in compartment fernando.harris</em></p><p><em>Allow dynamic-group emea-oke-dynamic-group to manage streampools in compartment fernando.harris</em></p><h3>Coding the consumerms micro-service</h3><p>The consumerms micro-service will need a couple of classes more to play with the Instance Principals. So, besides the OCI sdk core classes and sdk for streaming, we’ll also need som oci sdk identity classes and an addon for a resteasy client configurator:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/810/1*wyUpAyOD_nvio9j3epVZBA.png" /><figcaption>pom file for the consumerms micro-service</figcaption></figure><p>Once again let’s keep the OCI Streaming information in the <strong>application.properties</strong> file as configuration variables. Time time, besides the endpoint and id we also need the <strong>compartmentId</strong>. In this case, we are talking about the compartmentId of the compartment <em>fernando.harris where the stream curiosity is running:</em></p><p>Go to Identity &amp; Security &gt; Compartments:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*eHZJu87CyXsmtEdu0Vez8w.png" /><figcaption>Identity &amp; Security &gt; Compartments</figcaption></figure><p>Chose the compartment and copy its id:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TynJxglj7XWmWyYCSCCChw.png" /><figcaption>copy compartmentId</figcaption></figure><p>Now, prepare the application.properties file :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/624/1*T2UiKTkrHJO9e8GQndRd8g.png" /><figcaption>application.properties file</figcaption></figure><p>Our class <strong>OcisdkApplication</strong> will dynamically assign the values from the OCI Streaming configuration in the <strong>application.properties file </strong>as environment variables through<strong> @value</strong> annotation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/724/1*sfA_n8dR6ZmPnpQRdW-ilg.png" /></figure><p>Since now we intend to build and run this micro-service on OCI within Container Engine (OKE), we will not need to use an OCI configuration file and API Key to authenticate against Oracle Cloud Infrastructure. If this was the case, we would be following a big risk keeping that type of information inside our container image. So, we are going to use the Instance Principal concept we explained above. Lets see how to implement this code, and once again we have a method called <strong>prepareOCICall() </strong>which will deal with the authentication process:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GA2pc8G0_FY5vfsoy7IuCQ.png" /><figcaption>deal with the authentication process</figcaption></figure><p>This method will make use of the <strong>InstancePrincipalsAuthenticationDetailsProvider t</strong>o authenticate with Instance Principals and then build a <strong>streamClient</strong> with it associated with the <strong>streamEndpoint</strong>.</p><p>This method does 3 things:</p><ol><li>calls the authentication process with a call to <strong>prepareOCICall()</strong>,</li><li>prepares to consume the event which should be already published to the Stream</li><li>and finally consumes the event from the stream.</li></ol><p>This time the code will be running in the kubernetes cluster:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XuEvIzp4RGoxF2mMR_1tTw.png" /><figcaption>running in the kubernetes cluster</figcaption></figure><p>Checking the logs:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WU9VLq-bm6pPEIlVn5V0ug.png" /><figcaption>Note the successfull authentication and the cursor to the Stream created</figcaption></figure><p>Eventually, the service will consume the messages:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vVbIKuKG4YFQj9vTEICsLw.png" /><figcaption>application logs</figcaption></figure><p>And thats it.</p><p>Have fun trying it! <a href="https://github.com/fharris/consumerms">Here</a> you can get the consumerms code in my <a href="https://github.com/fharris/">github</a>.</p><h3>References:</h3><p>Practical Oracle Cloud Infrastructure: Infrastructure as a Service, Autonomous Database, Managed Kubernetes, and Serverless By <a href="https://learning.oreilly.com/search/?query=author%3A%22Micha%C5%82%20Tomasz%20Jak%C3%B3bczyk%22&amp;sort=relevance&amp;highlight=true">Michał Tomasz Jakóbczyk</a></p><ul><li><a href="https://blogs.oracle.com/developers/post/getting-your-feet-wet-with-oci-streams">Getting Your Feet Wet With OCI Streams</a></li><li><a href="https://docs.oracle.com/en-us/iaas/Content/Streaming/Tasks/streaming-quickstart-oci-sdk-for-java.htm">SDK for Java Streaming Quickstart</a></li><li><a href="https://docs.oracle.com/en-us/iaas/Content/Streaming/home.htm">Streaming</a></li></ul><p><a href="https://docs.oracle.com/en-us/iaas/Content/Identity/Tasks/managingdynamicgroups.htm">https://docs.oracle.com/en-us/iaas/Content/Identity/Tasks/managingdynamicgroups.ht</a>m</p><ul><li><a href="https://blogs.oracle.com/developers/post/accessing-the-oracle-cloud-infrastructure-api-using-instance-principals">Accessing the Oracle Cloud Infrastructure API Using Instance Principals</a></li><li><a href="https://docs.oracle.com/en-us/iaas/Content/Identity/Concepts/policies.htm">How Policies Work</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=29e7fc2d09cc" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Kubernetes Service Operator for OCI Streaming — First steps]]></title>
            <link>https://medium.com/@HarrisNando/kubernetes-service-operator-for-oci-streaming-first-steps-f1a2fc3e6556?source=rss-b6254430356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1a2fc3e6556</guid>
            <category><![CDATA[kafka]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[streaming]]></category>
            <dc:creator><![CDATA[Fernando Harris]]></dc:creator>
            <pubDate>Sun, 31 Oct 2021 11:12:33 GMT</pubDate>
            <atom:updated>2021-12-22T12:18:41.570Z</atom:updated>
            <content:encoded><![CDATA[<h3>Kubernetes Service Operator for OCI Streaming — First steps</h3><p>Oracle Cloud Infrastructure ecosystem is open and ubiquitous, making available different standardised approaches to promote integration between services and making the life of developers and cloud architects much simpler.</p><p><a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengaddingosok.htm">Adding OCI Service Operator for Kubernetes to Clusters</a></p><p>The <strong>OCI Service Broker for Kubernetes</strong> was the de facto approach to make Oracle Container Engine and Kubernetes interact with OCI. But now, Oracle recommends the use of <strong>OCI Service Operator for Kubernetes</strong> <strong>(OSOK)</strong> to interact with Oracle Cloud Infrastructure services using the Kubernetes API and Kubernetes tooling. Take a look on the documentation <a href="https://docs.oracle.com/en-us/iaas/Content/ContEng/Tasks/contengaddingservicebrokers.htm">here</a> to start, but before that, get a coffee or a cup of tea, and during 10 minutes read this article and you’ll be good to go.</p><p>Well, more or less. This blog is just a complement for the Github project which really contains everything you need to know. What I offer you here is just an head start :) .</p><p>In this post we’ll be trying to connect the Oracle Container Engine aka OKE, with the OCI Streaming service in a secure way. The OCI Streaming service is a real-time, serverless, Apache Kafka-compatible event streaming platform for developers and data scientists.</p><p>OSOK is based on the <a href="https://operatorframework.io/">Operator Framework</a>, an <strong>open-source toolkit</strong> used to manage Operators in an automated and scalable way.</p><p>A fundamental concept is that of the <strong>Operator</strong>.</p><p>And what is an operator ?</p><p>To explain what an operator is, we need to start by explaining what a <a href="https://kubernetes.io/docs/concepts/extend-kubernetes/api-extension/custom-resources/"><strong>Customer Resource </strong></a>means in Kubernetes.</p><p><em>The documentation is straightforward: a custom resource</em> is simply an extension of the Kubernetes API which is not necessary available by default, i.e., its a resource which isn’t built in the K8s core. To define the new resource template we create a <strong>Customer Resource Definition CRD</strong> object, which is what in fact creates a new custom resource with a name and schema that you specify. After creating the new CRD, you will be able to manage its objects lifecycle with kubectl just as if they were any other default Kubernetes resource such as volumes or pods.</p><p>Without a controller, a resource will not do anything. Each resource , whether custom or built in, will have a specific controller responsible to manage and monitor the status of each one of its objects.</p><p>The controller is basicaly code running in a controlled loop listening to specific events affecting the type of resource the controller is looking at.</p><p>The job of the controller is to systematically monitor a resource while permanently watching for any changes or events occurring and associated with the resource.</p><p>However, custom resources and custom controllers are separate entities and we need to manage each one separately if we want to use them. This is when the Operator Framework makes its appearance as it allows to package and manage together Customer Resources and Custom Controllers, including deploying them and managing all their lifecycle.</p><p><a href="https://sdk.operatorframework.io/">https://sdk.operatorframework.io/</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HYMw45ZHl2EzUPZqCkYK-w.png" /></figure><h3>WHAT CAN I DO WITH OPERATOR SDK?</h3><blockquote>The Operator SDK provides the tools to build, test, and package Operators. Initially, the SDK facilitates the marriage of an application’s business logic (for example, how to scale, upgrade, or backup) with the Kubernetes API to execute those operations. Over time, the SDK can allow engineers to make applications smarter and have the user experience of cloud services. Leading practices and code patterns that are shared across Operators are included in the SDK to help prevent reinventing the wheel.</blockquote><p>The Operator SDK is a framework that uses the controller-runtime library to make writing operators easier by providing:</p><ul><li>High level APIs and abstractions to write the operational logic more intuitively</li><li>Tools for scaffolding and code generation to bootstrap a new project fast</li><li>Extensions to cover common Operator use cases</li></ul><p><a href="https://olm.operatorframework.io/">homepage</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vke9adBTjtfDFWNMXKpQXg.png" /></figure><p>The other important concept is the <strong>Operator Lifecycle Manager</strong> which “provides rich mechanisms to keep Kubernetes native applications up to date automatically”</p><h3>Lets start…</h3><p>Make sure you have an OKE cluster and proper access to it by running <strong>kubectl</strong> commands against the Kubernetes API. For example: <strong>kubectl get nodes</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hAq9XD3TwDuDEOaK1ZQ8ZA.png" /></figure><p>Don’t make a confusion with the OCI Service Broker:</p><blockquote><em>Instead of the OCI Service Broker for Kubernetes, Oracle now recommends you use the OCI Service Operator for Kubernetes to interact with Oracle Cloud Infrastructure services using the Kubernetes API and Kubernetes tooling.</em></blockquote><p>Again, the detailed instructions to install is in the <a href="https://github.com/oracle/oci-service-operator">OCI Service Operator for Kubernetes documentation in the Github repository</a>. In summary, there are 3 sequential steps to follow:</p><ol><li>Install OCI Service Operator for Kubernetes.</li><li>Secure OCI Service Operator for Kubernetes.</li><li>Provision and bind to the required Oracle Cloud Infrastructure services.</li></ol><p>We’ll be following the documentation and Github and do this step by step.</p><h3><strong>Part 1: Install OCI Service Operator for Kubernetes.</strong></h3><ul><li>Install the <a href="https://sdk.operatorframework.io/">Operator SDK</a>.</li></ul><p><a href="https://sdk.operatorframework.io/docs/installation/">Installation</a></p><p>In my case, I’m using a Mac:</p><h4>Install from Homebrew (macOS)</h4><pre>brew install operator-sdk</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-JtwGPVTa3fYMX2QMxtl0g.png" /><figcaption>brew install operator-sdk</figcaption></figure><p>2. Install the <a href="https://olm.operatorframework.io/">Operator Lifecycle Manager (OLM)</a></p><p><strong>$operator-sdk olm install</strong></p><p><strong>$operator-sdk olm status</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sxyNqY2jEdgBUGRtJNNuIg.png" /><figcaption>OLM install OK</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2gd6DGeLrGj6bfvL6fIRXA.png" /><figcaption>OLM resources created in K8 cluster</figcaption></figure><p>This will install a bunch of new resources in your cluster, including the creation of a couple of new namespaces: <strong>olm</strong> and <strong>operators</strong>:</p><p>Now, let’s deploy the OCI Service Operator for Kubernetes.</p><p>First things first, let’s get the OCID from the instances running in the node pool in the K8 cluster. You should be able to do this by visiting your cluster details and clicking the Nodes on the Resources on your OCI Console.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VbdGlLyUxeDSh24hWfUEWQ.png" /><figcaption>instances running in OKE Cluster node pool</figcaption></figure><p>Click each of the instances and copy its OCID to your notepad:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gjXj3u4atOrGuybs4yv0Nw.png" /><figcaption>getting instances OCID</figcaption></figure><p>As mentioned, repeat this last step for the other 2 instances running in the node pool. You should end up with something like this:</p><p><strong>Worker node 1:</strong></p><p>ocid1.instance.oc1.eu-frankfurt-1.antheljsmfkspnqcffjxhmiej2xrrwnjkj2r6wkesxwzg3ucij4v373ckaja</p><p><strong>Worker node 2:</strong></p><p>ocid1.instance.oc1.eu-frankfurt-1.antheljsmfkspnqcirlw72wfoczulmjfgr5kls3imqloep2nrxgkakebtboq</p><p><strong>Worker node 3:</strong></p><p>ocid1.instance.oc1.eu-frankfurt-1.antheljsmfkspnqcaxsh7br556fgkbeujszymladyntevk4ojiy7cakapllq</p><p>We are doing this because we need a way to let the node pools in the Kubernetes cluster interact with other OCI Services without the need to execute the typical authentication process with the OCI Client and SDK. We want to achieve proper Service interaction without the trouble of having to manage authentication against OCI through the OCI Client, SDK or whatever.</p><p>The standard way to do this in OCI is with the Instance Principals and Dynamic Groups. According to the documentation, Dynamic groups allow you to group Oracle Cloud Infrastructure compute instances as “principal” actors (similar to user groups). You can then create policies to permit instances to <a href="https://docs.oracle.com/en-us/iaas/Content/Identity/Tasks/callingservicesfrominstances.htm#Calling_Services_from_an_Instance">make API calls against Oracle Cloud Infrastructure services</a>. When you create a dynamic group, rather than adding members explicitly to the group, you instead define a set of <em>matching rules</em> to define the group members. For example, a rule could specify that all instances in a particular compartment are members of the dynamic group. The members can change dynamically as instances are launched and terminated in that compartment.</p><p><a href="https://docs.oracle.com/en-us/iaas/Content/Identity/Tasks/managingdynamicgroups.htm#Managing_Dynamic_Groups">Managing Dynamic Groups</a></p><p><a href="https://docs.oracle.com/en-us/iaas/Content/Identity/Tasks/managingdynamicgroups.htm#">To create a dynamic group</a> using the Console:</p><ol><li>Open the navigation menu and click <strong>Identity &amp; Security</strong>. Under <strong>Identity</strong>, click <strong>Dynamic Groups</strong>.</li><li>Click <strong>Create Dynamic Group</strong>.</li><li>Enter the following:</li></ol><ul><li><strong>Name:</strong> A unique name for the group. The name must be unique across all groups in your tenancy (dynamic groups and user groups). You can’t change this later. Avoid entering confidential information.</li><li><strong>Description:</strong> A friendly description.</li></ul><ol><li>Enter the <strong>Matching Rules</strong>. Resources that meet the rule criteria are members of the group.</li></ol><p>The rule matches the kubernetes worker instance ocid or the compartment where the worker instances are running, which you got it above:</p><p>You should be able to build something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Wac4ZVUGp78Hgmf_zztNPA.png" /><figcaption>Rules for new Dynamic Group</figcaption></figure><p>Any {instance.id = ‘ocid1.instance.oc1.eu-frankfurt-1.antheljsmfkspnqcffjxhmiej2xrrwnjkj2r6wkesxwzg3ucij4v373ckaja’, instance.id = ‘ocid1.instance.oc1.eu-frankfurt-1.antheljsmfkspnqcirlw72wfoczulmjfgr5kls3imqloep2nrxgkakebtboq’, instance.id = ‘ocid1.instance.oc1.eu-frankfurt-1.antheljsmfkspnqcaxsh7br556fgkbeujszymladyntevk4ojiy7cakapllq’, instance.compartment.id = ‘ocid1.compartment.oc1..aaaaaaaaupdkb2xhrcm3vk422rqq5wt4uc5hhywwxsyaw7ay2qciohrjcjbq’}</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oB_bvqQkzIGVvDzjFy5cBA.png" /><figcaption>Creating a Dynamic Group in OCI</figcaption></figure><p>Next, to give the dynamic group the permissions you need, you will need to write a policy. The policy must be tenancy wide or in the compartment for the dynamic group created above:</p><p>From the documentation in Github we can get a couple of examples:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LHtDldLFctAQ3nqHTLv9Jg.png" /><figcaption>Policies examples in Github</figcaption></figure><p>The references in the example for &lt;OCI_SERVICE_1&gt;, &lt;OCI_SERVICE_2&gt;, etc, represents the OCI Services like “autonomous-database-family”, “instance_family”. Keep in mind that at the moment I write this article, 3 OCI Services are supported by the Operator: Autonomous Database, MySQL PaaS and OCI Streaming.</p><p>In our example we will work with the <strong>OCI Streaming</strong>.</p><p>The OCI Policy Builder is a very intuitive tool to build these policies. Take a look on the below link to find more info about Policies for accessing Services in OCI:</p><p><a href="https://docs.oracle.com/en-us/iaas/Content/Identity/Tasks/callingservicesfrominstances.htm">Calling Services from an Instance</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jBnbflByW2D0pR5sovTQ6w.png" /><figcaption>Policy builder in OCI Console</figcaption></figure><p><strong>Policy Statements</strong></p><p>Allow dynamic-group <strong>okeoperatordynamicgroup</strong> to manage streams in <strong>compartment okeSharedCompartment</strong></p><p>Don’t forget to create a similar policy on the Tenancy level as well:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TzNyZ0FtNPDOzsD9TQF5iQ.png" /><figcaption>policies tenancy level</figcaption></figure><p>And thats it. Let’s now move to the second part and secure the OCI Service Operator.</p><h3><strong>PART2: Secure OCI Service Operator for Kubernetes.</strong></h3><p>Best practices for the OCI Service Operator for Kubernetes demands the OCI user credentials details to provision and manage OCI services and resources in the tenancy.</p><p>The OSOK will be deployed in oci-service-operator-system namespace. For enabling user principals, we need to create the namespace before deployment.</p><p>Create a yaml file using the example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/634/1*fdD4yzzLx4-2-MpefkSUuw.png" /><figcaption>yaml to create operator</figcaption></figure><p>in my case,</p><pre>$ kubectl apply -f serviceoperatorokenamespace.yml</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0g5kbac5TT36r1Q7XrGrZw.png" /></figure><p>The user is required to create a Kubernetes secret as detailed below.</p><p>For that get the OCI user credentials to create a Kubernetes secret. I’m going to use my own OCI user, but in theory a specific user to enable the User Principle should be used:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/842/1*4ZL5eRRFjuGR5wq2SNuvTw.png" /><figcaption>OCI Credentials for my user</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZSJz8DqhWnLCtfcYxQNHLQ.png" /><figcaption>Description for credentials from documentation</figcaption></figure><p>The name of the secret will passed in the osokConfig config map which will be created as part of the OSOK deployment. By default the name of the user credential secret is ocicredentials. Also, the secret should be created in the oci-service-operator-system namespace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RU3S_7pov013mzqlRiTb2A.png" /><figcaption>create secret with kubectl for my user credentials</figcaption></figure><p>The OCI user owning the above credentials should be added to a IAM group osok-operator-group. An OCI Policy that can be tenancy wide or in the compartment to manage the OCI Services should also be created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cCGQIZ7bB14uqvNKdFWT9A.png" /><figcaption>Policies examples</figcaption></figure><pre>### Tenancy based OCI Policy for user<br>Allow group &lt;OSOK_OPERATOR_GROUP&gt; to manage &lt;OCI_SERVICE_1&gt; in tenancy</pre><pre>### Compartment based OCI Policy for user<br>Allow group &lt;OSOK_OPERATOR_GROUP&gt; to manage &lt;OCI_SERVICE_1&gt; in compartment &lt;NAME_OF_THE_COMPARTMENT&gt;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XIH9v_j4t-oisQcLR94tdA.png" /><figcaption>Create IAM Group</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xY1T4zgWIHAKIiU1FPLrPA.png" /><figcaption>Create Policy for the Group a tenancy level</figcaption></figure><p>Allow group <strong>osok-operator-group</strong> to manage streams in <strong>tenancy interactivetech (root)</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GhqvulGBXbl5bQkqyZwTqw.png" /><figcaption>create policy for the group at compartment level</figcaption></figure><p>You should end up with a set of policies as described in below print screens<strong>**</strong>:</p><p><strong>Policies resume at Tenancy level:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AqGbrKcU53d6MjbI0mmlNg.png" /><figcaption>Policies resume at Tenancy Level</figcaption></figure><p><strong>Policies resume at Compartment level:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SlvEHFm_jrCq64yUkFQ4-Q.png" /><figcaption>Policies resume at Compartment level</figcaption></figure><h3>Deploy OSOK on K8</h3><p>Having everything in place on OCI side, we can get back to the Operator and Kubernetes:The bundle can be downloaded as docker image using below command. You’re probably very familiar with this process, but make sure your Docker engine is running 🏃‍♀️ 🏃‍♂️ …I always forget…. ;)</p><blockquote>The OCI Service Operator for Kubernetes is packaged as Operator Lifecycle Manager (OLM) Bundle for making it easy to install in Kubernetes Clusters. The bundle can be downloaded as docker image using below command.</blockquote><pre>$ docker pull iad.ocir.io/oracle/oci-service-operator-bundle:1.0.0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6pg2lfiG7g4YoxAgPicTlw.png" /><figcaption>docker pull service operator docker image</figcaption></figure><blockquote>The OSOK OLM bundle contains all the required Kubernetes resources such as CRDs, RBACs, Configmaps, deployments which will install the OSOK in your Kubernetes cluster.</blockquote><p>Run below command to start installing the resources in the cluster:</p><pre>$ operator-sdk run bundle iad.ocir.io/oracle/oci-service-operator-bundle:1.0.0</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*q9Prr_2K7CYmf4IfGAeF4w.png" /></figure><h3>Part 3: Provision and bind to the required OCI services.</h3><p>The 3rd and final step is here and is when you will basically do things such as:</p><ul><li>Provide service provision request parameters.</li><li>Provide service binding request parameters.</li><li>Provide service binding response credentials.</li></ul><p>Click <a href="https://github.com/oracle/oci-service-operator/tree/main/config/samples">here</a> to take a quick look and check the examples in the documentation. They are not very detailed, but simple enough to understand the dynamic to create the bindings with OCI Services such as Autonomous Database, MySQL PaaS and OCI Streaming.</p><h3>Oracle Streaming Service and OSOK</h3><p><a href="https://github.com/oracle/oci-service-operator/blob/main/docs/oss.md#oracle-streaming-service">Here</a>, you will find more detailed information on how to implement the samples for the OCI Streaming service.</p><p>Let’s start by creating a binding with an existing stream. In OCI, go to Analytics &amp; AI an then Streaming:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vlGFBELxQqGnb-0tkp4DPA.png" /><figcaption>Streaming in OCI Console</figcaption></figure><p>See the list of active Streams in the compartment:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fiptn6nljxhN-HrqYywJ2w.png" /><figcaption>List of existing streams</figcaption></figure><p>We want to bind with the curiositypointsdummy stream. To do that, we need the stream OCID. Then prepare a yaml manifest to send to your K8 cluster. I’ve named it as CR_OSOK_BindExistingStream.yaml and its content is below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IbI6B_1sc9E1SEKXBolmJg.png" /><figcaption>yaml to bind to an existing stream with OCID</figcaption></figure><p>run <strong>$kubectl apply -f CR_OSOK_BindExistingStream.yaml</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5qUBCHt7we_lcgKqGq7zNA.png" /></figure><p>run</p><p>$kubectl get stream curiositypointsdummy -o wide</p><p>and get the details for the binding:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OV-h_fe9QgNxYrsB8260mg.png" /></figure><p>Let’s now create a new stream:</p><p>Prepare a yaml template like the example below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sPvbgsdDxQ37YxreOw8u1A.png" /></figure><p>In my case I named it as CR_OSOK_CreateStream.yaml. Run</p><p>$ kubectl apply -f CR_OSOK_CreateStream.yaml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aOmxWoXnRclXEAwmpLWRZg.png" /></figure><p>run :</p><p>$ kubectl get stream createstreamarticle -o wide</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*91Kw_zzg6PSJ4MQ9F9NQaw.png" /></figure><p>You’ll see you now have a new stream created and active with its OCID.</p><p>To get more details about this resource run:</p><p>$ kubectl describe stream createstreamarticle</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HKJ8iYOZiWH68A_v2_qYBg.png" /><figcaption>New Stream, details 1.2</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OCjVJyGYe0HS765N5FHMZg.png" /><figcaption>New Stream, details 2.2</figcaption></figure><p>Lets validate in the OCI Console:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4fJZ22OuWOcbxLjmdjAWqA.png" /><figcaption>List of existing streams in the compartment</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OycQEYdrMBGNJkO1RyJsVw.png" /><figcaption>New stream created</figcaption></figure><p>As expected, a new stream called <strong>StreamDummyCROperatorArticle</strong> is now created.</p><p>Some final notes and recommendations from my experience:</p><p>Check your permissions, policies and groups and dynamic groups. If you get a 404 , it’s highly probable that your are doing something wrong on one of these steps. The kubectl describe command is essencial to troubleshoot this type of event.</p><p>When you run a kubectl describe and it seems the list of events are not getting updated , it can be because OCI is not allowing or releasing the creating of new streams, maybe your partition limit was hit. In my case, after deleting a Stream with many partitions I start seeing immediately the creation of the new streams. This type of behaviour will not happen if you are trying to bind to an existing stream.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rXsbTtFuKCNEuOIA5iwRPA.png" /><figcaption>Events for the resource creation</figcaption></figure><p>In the OCI Streaming link you’ll find more policies created in OCI. The print screens I shared above as a summary of the needed policies<strong>**,</strong> reflect already that.</p><p><strong>More References:</strong></p><p><a href="https://blogs.oracle.com/cloud-infrastructure/authors/Blog-Author/CORE8BD4E307E80F4FBFB757925EC804D365/mickey-boxell">Mickey Boxell</a> blog is a very nice article to do a similar exercise with the MySQL service:</p><p><a href="https://blogs.oracle.com/cloud-infrastructure/post/oci-service-operator-for-kubernetes">OCI Service Operator for Kubernetes</a></p><p><a href="https://twitter.com/kmensah">Kuassi Mensah</a> blog post for the same topic is also very interesting:</p><p><a href="https://kuassimensah.medium.com/making-oracle-database-kubernetes-native-401233c02780">https://kuassimensah.medium.com/making-oracle-database-kubernetes-native-401233c02780</a></p><p>Cheers,</p><p>Have fun</p><p>Fernando</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1a2fc3e6556" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Java Webservice with Basic Authentication]]></title>
            <link>https://medium.com/@HarrisNando/java-webservice-with-basic-authentication-9899349b85d?source=rss-b6254430356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/9899349b85d</guid>
            <category><![CDATA[weblogic]]></category>
            <category><![CDATA[web-services]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[security]]></category>
            <dc:creator><![CDATA[Fernando Harris]]></dc:creator>
            <pubDate>Sun, 05 Jul 2020 14:28:45 GMT</pubDate>
            <atom:updated>2020-07-05T14:28:45.527Z</atom:updated>
            <content:encoded><![CDATA[<p>In a RestFul microservice World, moved by JSON, gRFC and other fancy, light protocols, SOAP became the ugly duck.</p><p>But that doesn’t mean that many of its positive traits are no longer valid.</p><p>For those, still running new and legacy systems in Weblogic or other Java Application Servers, the exercise below is very simple and can be very useful.</p><p>First step, open your Eclipse JEE and create a new Project:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f0xGqU6RxOIxEVoY_hs3Jg.png" /></figure><p>In the wizard choose the Oracle folder. Make sure you have installed it beforehand in your Eclipse.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WtSvuEA9S6FXzKKwL3D3iw.png" /></figure><p>Define your project like this</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FLDm7Wy1NSclrOvCCPX75A.png" /></figure><p>Click Next. Leave it like this…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AVnjO8TNzwq4K-XyOcrvjQ.png" /></figure><p>Don’t forget to generate the web.xml descriptor file:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*knqzuwDk_imLg2jObicLlA.png" /></figure><p>Click Finish and Wait:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfvjT-MKcu9r7tIk_VdX_Q.png" /></figure><p>When generated, you should have something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fygvttmhw90Z1rpZ4Jc8ww.png" /></figure><p>From the Java Resources src folder, generate a new Weblogic Web Service:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SGrf-AFTRk3B1Fj2elFj_w.png" /></figure><p>Create your new webservice:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*o2eoFeKeu1hwFLfFInUAIA.png" /></figure><p>With No policies and Finish:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LPabuEI-vNi7OVt2IvuTxg.png" /></figure><p>You should get something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zSYEEaVVkyh3LnSrn2JgxA.png" /></figure><p>Make this changes in your class:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xRED5wykGhUhEvYG8nqAiA.png" /></figure><p>Click the method name and the parameter if you want to generate annotations automatically:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OW4IAtcRUcpUMzLEE98VIA.png" /></figure><p>Now, lets add the Basic Authentication part.</p><p>Edit your web.xml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*sWRIR1EOdjWC_aS_94kxXA.png" /></figure><p>And weblogic.xml</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ROAwh0-kAoKK-KRbXzXDaw.png" /></figure><p>The principal-name in the weblogic.xml should represent a User or Group that you already have created in Weblogic:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QNeSi6T-mbQOXx5ebpet4w.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZkXn7KG_bTIHBkvXGehBIw.png" /></figure><p>Now , you can export your webservice as an EAR and deploy it in Weblogic.</p><p>When finished, in Weblogic you can obtain the WSDL from the Testing folder:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FbDqxbdwNj7Zng8uB8rFDw.png" /></figure><p>After that you just need to test it with SOAP UI.</p><p>First test without Authentication is unsuccessful :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*au1Pi0ExUGapRxctSP8D-A.png" /></figure><p>Second try, this time with Basic Authentication in place is successful :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KQyuntIJmXVQaT6oOyH03A.png" /></figure><p>That’s it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9899349b85d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JenkinsX in Oracle Container Engine: part 1 — creating a k8s cluster]]></title>
            <link>https://medium.com/@HarrisNando/jenkinsx-in-oracle-container-engine-part-1-creating-a-k8s-cluster-d5ad9c49bcc2?source=rss-b6254430356c------2</link>
            <guid isPermaLink="false">https://medium.com/p/d5ad9c49bcc2</guid>
            <category><![CDATA[jenkins]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[oracle-cloud]]></category>
            <category><![CDATA[jenkins-x]]></category>
            <category><![CDATA[gitops]]></category>
            <dc:creator><![CDATA[Fernando Harris]]></dc:creator>
            <pubDate>Fri, 01 Mar 2019 19:59:21 GMT</pubDate>
            <atom:updated>2019-03-01T19:59:21.550Z</atom:updated>
            <content:encoded><![CDATA[<h3>JenkinsX in Oracle Container Engine: part 1 — creating a k8s cluster</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/125/1*kkm1mAkjnOM-Fm9hiLVSTA.png" /><figcaption>jenkinsX logo</figcaption></figure><p>Few months ago I was attending one of the VJUG <a href="https://virtualjug.com/">https://virtualjug.com/</a> virtual sessions and the subject was <strong>JenkinsX </strong>and <strong>GitOps</strong>. I was impressed by the concept and anxious to test it.</p><p>According to the their own definition in <a href="https://jenkins.io/projects/jenkins-x/">https://jenkins.io/projects/jenkins-x/</a> :</p><blockquote>“Jenkins X has the concepts of Apps and Environments built in. You do not directly install Jenkins to use Jenkins X, Jenkins is embedded as a pipeline engine as part of the installation for a team. Jenkins X does not aim to replace Jenkins, but builds on it with best of breed open source tools.</blockquote><blockquote>Think of it as a great way to achieve CI/CD with batteries included, without having to assemble things together yourself.</blockquote><p>This is a project which is still in progress and so I believe that many other features will eventually be released. At the moment I test it I could basically start with 2 options:</p><p><strong>a) Create from scratch a kubernetes cluster with jenkinsX</strong></p><p><strong>b) Import jenkinx into an existing kubernetes cluster</strong></p><p>I’ve chosen option a) and the following steps will describe my experience.</p><p>Notice that the following requirements are needed in order to do this exercise:</p><p><strong>Access to a kubernetes managed service</strong>. In my case I’ve used OKE or Oracle Container Engine. <a href="https://cloud.oracle.com/containers/kubernetes-engine">https://cloud.oracle.com/containers/kubernetes-engine</a>. Special attention must be given to the fact that a VCN should already exist in the OCI compartment where you’re going to create the cluster.</p><p><strong>OCI Client:</strong> you should have installed OCI Client or OCI Cli for Oracle Cloud Infrastructure. The is a python based client which makes it very easy to consume OCI REST APIs. <a href="https://docs.cloud.oracle.com/iaas/Content/API/Concepts/cliconcepts.htm">https://docs.cloud.oracle.com/iaas/Content/API/Concepts/cliconcepts.htm</a> . I’ve used version 2.4.42</p><p><strong>jx command line:</strong> The jenkinsX command line or jx client <a href="https://jenkins-x.io/">https://jenkins-x.io/</a> . I’ve used jx version 1.3.899.</p><p>My OS is a Ubuntu 16.04 LS.</p><p>All this preparation steps can be followed in <a href="https://jenkins-x.io/getting-started/">https://jenkins-x.io/getting-started/</a> and <a href="https://blogs.oracle.com/cloud-infrastructure/cicd-on-steroids:-announcing-container-engine-for-kubernetes-as-a-jenkins-x-provider">https://blogs.oracle.com/cloud-infrastructure/cicd-on-steroids:-announcing-container-engine-for-kubernetes-as-a-jenkins-x-provider</a> for a more detailed approach or complementary information.</p><p>So, to create the cluster I’ve executed the following command with jx:</p><p><strong>$ jx create cluster oke</strong></p><p>First thing showing is the prompt for the cluster configuration to specify the region, the VCN id, the version of kubernetes to install, the node shapes and the subnets for the Load Balancer. In few minutes the cluster will be ready ….</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*btJBYe8uHW4OXCWuV49M1g.jpeg" /></figure><p>and immediately the nodes will start to be created…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zbWCCrIsc1RZuexCCaIU4w.jpeg" /></figure><p>…after a few minutes the nodes are created as well…</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rBNGOOS5EDoAJZp14RbNkQ.png" /></figure><p>… and the process gets in another phase. In this phase the <strong>jx namespace </strong>will be created in the k8s cluster. Along with it helm and tiller will also be installed.</p><p>Proper admin roles will be assigned to the cluster and a git repository is configured. Finally a nginx-ingress-controller is also created :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hXflsUwjJmoth6M4wFjtcQ.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2aslyfuM7y4sDbW_FZz2zg.png" /></figure><p>The final steps are related with jenkins installing and the configuration of staging and production pipelines with respective git repositories:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4DFdEWMP_bIJIoZQOqeP6A.jpeg" /></figure><p>As the process is finished we can take a look on how it looks like the project configuration in jenkins:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kTR4C4-GXTUed6uf2WG-Ig.jpeg" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dknWlKbSuM4h4yd1cny-og.jpeg" /></figure><p>Your github should also reflect this, as two repositories were created, one for each pipeline:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*umrA4vJZefu1_lWuHZJqGQ.png" /></figure><p>In OCI dashboard we can confirm that the K8s cluster and its nodes were created successfully:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tmRPWI8UrFogimDKY5VMNA.jpeg" /></figure><p>And finally, after getting the kubeconfig file, proxy forwarding the kubernetes service allow us to take a look into the kubernetes dashboard where we can confirm that all the resources previously created in the jx namespace exist and live healthy and happy:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*boH_cmpnGrn3L0HbNCxLqQ.png" /></figure><p>It was a very cool exercise and an extremely interesting way to create a managed kubernetes cluster and a fully ready and set CI/CD pipeline based environment to implement GitOps.</p><p>In the second part of this article I will show how to use this CI/CD pipeline.</p><p><strong>References:</strong></p><p><a href="https://jenkins.io/projects/jenkins-x/">https://jenkins.io</a></p><p><a href="https://github.com/jenkins-x">https://github.com/jenkins-x</a></p><p><a href="https://blogs.oracle.com/cloud-infrastructure/cicd-on-steroids:-announcing-container-engine-for-kubernetes-as-a-jenkins-x-provider">https://blogs.oracle.com/cloud-infrastructure/cicd-on-steroids:-announcing-container-engine-for-kubernetes-as-a-jenkins-x-provider</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d5ad9c49bcc2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>