<?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 Jimoh Abdulrahman on Medium]]></title>
        <description><![CDATA[Stories by Jimoh Abdulrahman on Medium]]></description>
        <link>https://medium.com/@jimoh_abdol?source=rss-7f144da93169------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*mYnDdaJsZF14muY87XAQkw.jpeg</url>
            <title>Stories by Jimoh Abdulrahman on Medium</title>
            <link>https://medium.com/@jimoh_abdol?source=rss-7f144da93169------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 21 Nov 2026 22:53:41 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jimoh_abdol/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[“We’re Calling the Right API!” -Proving Our Innocence with tcpdump]]></title>
            <link>https://medium.com/@jimoh_abdol/were-calling-the-right-api-proving-our-innocence-with-tcpdump-47fb0b8a9eb8?source=rss-7f144da93169------2</link>
            <guid isPermaLink="false">https://medium.com/p/47fb0b8a9eb8</guid>
            <dc:creator><![CDATA[Jimoh Abdulrahman]]></dc:creator>
            <pubDate>Mon, 17 Nov 2025 12:31:29 GMT</pubDate>
            <atom:updated>2025-11-17T12:55:30.068Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*noVgtsgr30RljLM7p8YYXA.jpeg" /><figcaption>photo credit: <a href="https://www.linkedin.com/in/jvans/">https://www.linkedin.com/in/jvans/</a></figcaption></figure><h3>Background Story</h3><p>A few weeks ago, I got a message from one of our developers:</p><blockquote>“Jimoh, need your help. One of our 3rd-party partners says we are still hitting their old API endpoint even though we have already updated the config. Can you help the team prove we’re calling the right endpoint?”</blockquote><p>Issues like this are common in different environments, stale configs, misrouted traffic, or simply outdated assumptions. The best way to settle the debate?<br> <strong>Capture the actual network traffic from inside the pod</strong> and prove exactly where requests are going.</p><p>This guide walks you through how I troubleshoot such issues using a privileged debug pod running the nicolaka/netshoot image to execute tcpdump directly inside a pod&#39;s network namespace in Kubernetes.</p><h3>Step-by-Step Procedure</h3><h4>Identify the Target Pod and Node</h4><p>You need to know the pod you’re troubleshooting and which node it’s running on:</p><pre>kubectl get pods -n &lt;namespace&gt;<br>kubectl get pod &lt;pod-name&gt; -n &lt;namespace&gt; -o wide</pre><h4>Deploy a Debug Pod with Network Tools</h4><p>Create a privileged pod on the same node as the target pod:</p><pre>apiVersion: v1<br>kind: Pod<br>metadata:<br>  name: node-debug-netshoot<br>  namespace: default<br>spec:<br>  nodeName: &lt;TARGET_NODE_NAME&gt;   # Replace with actual node name<br>  hostNetwork: true<br>  hostPID: true<br>  hostIPC: true<br>  containers:<br>  - name: debug<br>    image: nicolaka/netshoot:latest<br>    command: [&quot;/bin/bash&quot;, &quot;-c&quot;, &quot;sleep 3600&quot;]<br>    securityContext:<br>      privileged: true<br>      runAsUser: 0<br>    volumeMounts:<br>    - name: host<br>      mountPath: /host<br>  volumes:<br>  - name: host<br>    hostPath:<br>      path: /<br>  tolerations:<br>  - operator: Exists<br>  restartPolicy: Never</pre><p>Deploy the debug pod:</p><pre>kubectl apply -f node-debug-netshoot.yaml</pre><h4>Access the Debug Pod</h4><pre>kubectl exec -it node-debug-netshoot -- bash</pre><h4>Capture Network Traffic</h4><h4>Set Variables</h4><pre>POD_NAME=app-ms-865f4ddb95-972bn<br>NAMESPACE=prod</pre><h4>Find Pod’s Container ID and Network Namespace</h4><pre>pod_id=$(chroot /host crictl pods --namespace ${NAMESPACE} --name ${POD_NAME} -q)<br><br>ns_path=$(chroot /host bash -c &quot;crictl inspectp $pod_id | \<br>jq &#39;.info.runtimeSpec.linux.namespaces[]|select(.type==\&quot;network\&quot;).path&#39; -r&quot;)</pre><h4>Start TCP Dump</h4><p>Capture all traffic:</p><pre>nsenter --net=/host${ns_path} -- tcpdump -nn -i eth0 \<br>  -w /host/tmp/capture_$(date +%d_%m_%Y-%H_%M_%S).pcap</pre><h4>Specific Filters</h4><p>Traffic to a specific host &amp; port:</p><pre>nsenter --net=/host${ns_path} -- tcpdump -nn -i eth0 \<br>  &#39;host 11.11.11.11 and port 4598 or host 10.10.0.5 and port 80&#39; \<br>  -w /host/tmp/capture_$(date +%d_%m_%Y-%H_%M_%S).pcap</pre><p>Only TCP traffic on certain ports:</p><pre>nsenter --net=/host${ns_path} -- tcpdump -nn -i eth0 \<br>  &#39;tcp port 4598 or tcp port 80&#39; \<br>  -w /host/tmp/capture_$(date +%d_%m_%Y-%H_%M_%S).pcap</pre><h4>Retrieve the Capture File</h4><p>Stop tcpdump with <strong>Ctrl + C</strong>, then list the files:</p><pre>ls -lh /host/tmp/capture_*.pcap</pre><p>Copy it locally:</p><pre>kubectl cp node-debug-netshoot:/host/tmp/capture_&lt;timestamp&gt;.pcap ./capture.pcap</pre><h4>Analyse the Capture in Wireshark</h4><p>Open the .pcap file in Wireshark.</p><h4>Cleanup</h4><pre>kubectl delete pod node-debug-netshoot</pre><h3>Final Thoughts</h3><p>This workflow has saved me countless hours. Whether you are validating API calls, debugging connectivity, or resolving disputes with external vendors, <em>a tcpdump never lies</em>.</p><p>Next time someone says, <em>“We think your service is calling the wrong endpoint,”</em> you can confidently capture the traffic and prove what is really happening.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=47fb0b8a9eb8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Ingress NGINX is Retiring]]></title>
            <link>https://medium.com/@jimoh_abdol/ingress-nginx-is-retiring-515c9a291153?source=rss-7f144da93169------2</link>
            <guid isPermaLink="false">https://medium.com/p/515c9a291153</guid>
            <dc:creator><![CDATA[Jimoh Abdulrahman]]></dc:creator>
            <pubDate>Sat, 15 Nov 2025 19:11:44 GMT</pubDate>
            <atom:updated>2025-11-15T19:11:44.231Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/1*aWLZcJdxMnGfMVtdAxKdtg.jpeg" /></figure><p>Kubernetes SIG Network and the Security Response Committee just announced the retirement of Ingress NGINX, one of the most widely used ingress controllers in the ecosystem.</p><p>Best-effort maintenance continues until March 2026. After March 2026: No new releases, no bugfixes, no security updates</p><p><strong>Why This Matters:</strong><br>Ingress NGINX has powered billions of requests worldwide and has been a cornerstone of countless Kubernetes deployments. However, the project has faced long-standing challenges:<br>- Maintained by just 1–2 volunteers working in their spare time<br>- Accumulated significant technical debt from legacy features<br>- Security concerns around features like “snippets” annotations<br>- Insufficient community support despite multiple calls for help</p><p>What You Need to Do:<br>Check if you’re using it: `kubectl get pods — all-namespaces — selector app.kubernetes.io/name=ingress-nginx`<br>Start planning your migration <strong>NOW</strong><br>Consider these alternatives: <br>- Gateway API (the modern replacement for Ingress) <br>- Other Ingress controllers listed in the Kubernetes docs <br>- Cloud-provider specific solutions</p><p>The Good News:<br>Your existing deployments won’t break immediately. Installation artifacts and container images will remain available. But without security updates post-March 2026, running it becomes increasingly risky.</p><p>Huge thanks to the Ingress NGINX maintainers for the years of incredible dedication. This project helped make Kubernetes what it is today.</p><p>Time to start planning that migration strategy!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=515c9a291153" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Building a Custom RabbitMQ Exporter for Better Queue Monitoring]]></title>
            <link>https://medium.com/@jimoh_abdol/building-a-custom-rabbitmq-exporter-for-better-queue-monitoring-53fb0493a634?source=rss-7f144da93169------2</link>
            <guid isPermaLink="false">https://medium.com/p/53fb0493a634</guid>
            <dc:creator><![CDATA[Jimoh Abdulrahman]]></dc:creator>
            <pubDate>Sat, 09 Aug 2025 12:18:58 GMT</pubDate>
            <atom:updated>2025-08-09T15:19:46.146Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/275/1*rvGTTtdUadRHrJtXAcy65g.png" /></figure><p>We kept receiving alerts from Prometheus Alertmanager, and we were unsure which of the queues were affected until someone logged into the RabbitMQ management console to check the queues. Diyan, the CTO, buzzed me to find a way we can proactively monitor the queue instead of the reactive approach.</p><p>The official RabbitMQ Prometheus plugin provides basic metrics, but we needed more granular, queue-level insights. So I built a custom exporter.</p><p>A Go based exporter that wraps the RabbitMQ Management API to provide enhanced queue metrics. Instead of monitoring individual metrics, the calculateHealthMetrics function calculates the queue health.</p><p><strong>Purpose</strong><br>This function calculates a health score for RabbitMQ queues and generates alerting metrics based on three key performance indicators:<br>- Queue depth (number of messages)<br>- Consumer utilization<br>- Message redelivery rate</p><p><strong>Health Score Calculation (0–100 scale)</strong><br>The function starts with a perfect health score of 100 and applies penalties based on problematic conditions:</p><pre><br>func (c *Collector) calculateHealthMetrics(queue rabbitmq.Queue, labels []string) {<br> healthScore := 100.0<br><br> if queue.Messages &gt; 1000 {<br>  healthScore -= 20<br> }<br> if queue.Messages &gt; 10000 {<br>  healthScore -= 30<br> }<br><br> if queue.ConsumerUtilisation &lt; 0.1 {<br>  healthScore -= 25<br> }<br> if queue.ConsumerUtilisation &lt; 0.01 {<br>  healthScore -= 40<br> }<br><br> redeliverRate := queue.GetRedeliverRate()<br> if redeliverRate &gt; 1.0 {<br>  healthScore -= 15<br> }<br> if redeliverRate &gt; 5.0 {<br>  healthScore -= 25<br> }<br><br> if healthScore &lt; 0 {<br>  healthScore = 0<br> }<br><br> c.metrics.QueueHealthScore.WithLabelValues(labels...).Set(healthScore)<br><br> if queue.Messages &gt; 1000 {<br>  c.metrics.QueueDepthAlert.WithLabelValues(append(labels, &quot;warning&quot;)...).Set(1.0)<br> } else {<br>  c.metrics.QueueDepthAlert.WithLabelValues(append(labels, &quot;warning&quot;)...).Set(0.0)<br> }<br> if queue.Messages &gt; 10000 {<br>  c.metrics.QueueDepthAlert.WithLabelValues(append(labels, &quot;critical&quot;)...).Set(1.0)<br> } else {<br>  c.metrics.QueueDepthAlert.WithLabelValues(append(labels, &quot;critical&quot;)...).Set(0.0)<br> }<br><br> if queue.ConsumerUtilisation &lt; 0.1 {<br>  c.metrics.QueueUtilizationAlert.WithLabelValues(append(labels, &quot;warning&quot;)...).Set(1.0)<br> } else {<br>  c.metrics.QueueUtilizationAlert.WithLabelValues(append(labels, &quot;warning&quot;)...).Set(0.0)<br> }<br> if queue.ConsumerUtilisation &lt; 0.01 {<br>  c.metrics.QueueUtilizationAlert.WithLabelValues(append(labels, &quot;critical&quot;)...).Set(1.0)<br> } else {<br>  c.metrics.QueueUtilizationAlert.WithLabelValues(append(labels, &quot;critical&quot;)...).Set(0.0)<br> }<br>}<br></pre><h4>Queue Depth Penalties:</h4><ul><li>-20 points if queue has &gt; 1,000 messages (indicates backlog)</li><li>-30 additional points if queue has &gt; 10,000 messages (severe backlog)</li><li>Total possible penalty: -50 points for extremely deep queues</li></ul><h4>Consumer Utilization Penalties:</h4><ul><li>-25 points if utilization &lt; 10% (consumers are underutilized)</li><li>-40 additional points if utilization &lt; 1% (consumers barely working)</li><li>Total possible penalty: -65 points for severely underutilized consumers</li></ul><h4>Redelivery Rate Penalties:</h4><ul><li>-15 points if redelivery rate &gt; 1 message/second (processing issues)</li><li>-25 additional points if redelivery rate &gt; 5 messages/second (serious processing problems)</li><li>Total possible penalty: -40 points for high redelivery rates</li></ul><h3>Metrics Generated</h3><p>The function outputs three Prometheus metrics:</p><ol><li>rabbitmq_custom_queue_health_score — The calculated health score (0–100)</li><li>rabbitmq_custom_queue_depth_alert — Binary alert for queue depth issues</li><li>rabbitmq_custom_queue_utilization_alert — Binary alert for consumer utilization issues</li></ol><p>All metrics are labelled with queue_name and vhost, while alert metrics include an additional severity label (“warning” or “critical”).</p><p>The circuit breaker was embedded directly in the Client struct and protects all API calls to RabbitMQ.</p><pre>func (c *Client) isCircuitOpen() bool {<br> c.mu.RLock()<br> defer c.mu.RUnlock()<br><br> if !c.circuitOpen {<br>  return false<br> }<br><br> if time.Since(c.lastFailureTime) &gt; c.resetTimeout {<br>  c.mu.RUnlock()<br>  c.mu.Lock()<br>  c.circuitOpen = false<br>  c.failureCount = 0<br>  c.mu.Unlock()<br>  c.mu.RLock()<br>  return false<br> }<br><br> return true<br>}</pre><ul><li>Auto-recovery: Circuit automatically transitions from OPEN → CLOSED after 60 seconds</li><li>Thread-safe: Uses read/write mutex for concurrent access</li><li>Smart reset: Resets failure count when circuit recovers</li></ul><h3>Installation</h3><ol><li>Clone the repository</li></ol><pre>git clone git@github.com:jimohabdol/rabbitmq-custom-exporter.git<br>cd rabbitmq-exporter</pre><p>2. Build the exporter</p><pre>make build</pre><p>3. Run the exporter</p><pre>./rabbitmq-exporter --rabbitmq-url=http://localhost:15672 --username=guest --password=guest</pre><h3>Docker</h3><pre># Build image<br>docker build -t rabbitmq-exporter .</pre><pre># Run container<br>docker run -p 9419:9419 \<br>  -e RABBITMQ_EXPORTER_RABBITMQ_URL=http://rabbitmq:15672 \<br>  -e RABBITMQ_EXPORTER_RABBITMQ_USERNAME=guest \<br>  -e RABBITMQ_EXPORTER_RABBITMQ_PASSWORD=guest \<br>  rabbitmq-exporter</pre><h3>️ Configuration</h3><p>Environment Variables</p><pre>RABBITMQ_EXPORTER_RABBITMQ_URL - RabbitMQ Management API URL (default: http://localhost:15672)<br>RABBITMQ_EXPORTER_RABBITMQ_USERNAME - RabbitMQ username (default: guest)<br>RABBITMQ_EXPORTER_RABBITMQ_PASSWORD - RabbitMQ password (default: guest)<br>RABBITMQ_EXPORTER_SCRAPE_INTERVAL - Scrape interval (default: 15s)<br>RABBITMQ_EXPORTER_LISTEN_PORT - HTTP server port (default: 9419)<br>RABBITMQ_EXPORTER_TIMEOUT - Request timeout (default: 10s)</pre><p>Configuration File</p><pre>rabbitmq_url: &quot;http://localhost:15672&quot;<br>rabbitmq_username: &quot;guest&quot;<br>rabbitmq_password: &quot;guest&quot;<br>scrape_interval: &quot;15s&quot;<br>listen_port: 9419<br>timeout: &quot;10s&quot;</pre><h3>Prometheus Configuration</h3><p>Add to your prometheus.yml:</p><pre>scrape_configs:<br>  - job_name: &#39;rabbitmq-custom&#39;<br>    static_configs:<br>      - targets: [&#39;localhost:9419&#39;]<br>    scrape_interval: 15s<br>    metrics_path: /metrics</pre><h3>Alerting Rules</h3><pre>groups:<br>  - name: rabbitmq-custom-alerts<br>    rules:<br>      # Circuit Breaker Alerts<br>      - alert: RabbitMQCircuitBreakerOpen<br>        expr: rabbitmq_custom_circuit_breaker_state{endpoint=&quot;rabbitmq_api&quot;} == 1<br>        for: 1m<br>        labels:<br>          severity: critical<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ API Circuit Breaker is OPEN&quot;<br>          description: &quot;The circuit breaker for RabbitMQ API endpoint has opened, indicating repeated failures to connect to RabbitMQ Management API. This means the exporter cannot collect metrics from RabbitMQ. Check if RabbitMQ is running and the Management Plugin is enabled. Verify network connectivity and authentication credentials.&quot;<br><br>      - alert: RabbitMQCircuitBreakerHalfOpen<br>        expr: rabbitmq_custom_circuit_breaker_state{endpoint=&quot;rabbitmq_api&quot;} == 2<br>        for: 30s<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ API Circuit Breaker is HALF-OPEN&quot;<br>          description: &quot;The circuit breaker for RabbitMQ API endpoint is in half-open state, testing if the connection has recovered. This indicates previous connection issues that may be resolving. Monitor for circuit breaker state changes.&quot;<br><br>      # Queue Depth Alerts<br>      - alert: RabbitMQQueueDepthWarning<br>        expr: rabbitmq_custom_queue_depth_alert{severity=&quot;warning&quot;} == 1<br>        for: 2m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has high message depth&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has accumulated a high number of messages (above warning threshold). This may indicate slow consumers or processing bottlenecks. Check consumer health and processing rates.&quot;<br><br>      - alert: RabbitMQQueueDepthCritical<br>        expr: rabbitmq_custom_queue_depth_alert{severity=&quot;critical&quot;} == 1<br>        for: 1m<br>        labels:<br>          severity: critical<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has CRITICAL message depth&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has accumulated a critical number of messages. This indicates severe processing delays or consumer failures. Immediate action required to prevent message loss and system degradation.&quot;<br><br>      # Consumer Utilization Alerts<br>      - alert: RabbitMQConsumerUtilizationWarning<br>        expr: rabbitmq_custom_queue_utilization_alert{severity=&quot;warning&quot;} == 1<br>        for: 3m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has low consumer utilization&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has low consumer utilization (below warning threshold). This may indicate insufficient consumer capacity or consumer scaling issues. Consider scaling up consumers or investigating consumer health.&quot;<br><br>      - alert: RabbitMQConsumerUtilizationCritical<br>        expr: rabbitmq_custom_queue_utilization_alert{severity=&quot;critical&quot;} == 1<br>        for: 2m<br>        labels:<br>          severity: critical<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has CRITICAL consumer utilization&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has critically low consumer utilization. This indicates severe consumer capacity issues or consumer failures. Immediate scaling or consumer restart required.&quot;<br><br>      # Consumer Count Alerts<br>      - alert: RabbitMQNoConsumers<br>        expr: rabbitmq_custom_queue_consumers == 0<br>        for: 1m<br>        labels:<br>          severity: critical<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has NO consumers&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has zero consumers connected. Messages will accumulate and not be processed. This indicates consumer application failures or deployment issues. Check consumer application status and restart if necessary.&quot;<br><br>      - alert: RabbitMQLowConsumerCount<br>        expr: rabbitmq_custom_queue_consumers &lt; 2<br>        for: 2m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has low consumer count&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has fewer than 2 consumers. This may indicate consumer scaling issues or partial consumer failures. Consider scaling up consumers for better fault tolerance.&quot;<br><br>      # Queue Health Score Alerts<br>      - alert: RabbitMQQueueHealthDegraded<br>        expr: rabbitmq_custom_queue_health_score &lt; 80<br>        for: 2m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} health is degraded&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has a health score of {{ $value }} (below 80). This indicates various health issues including high message depth, low consumer utilization, or other queue problems. Investigate queue performance and consumer health.&quot;<br><br>      - alert: RabbitMQQueueHealthCritical<br>        expr: rabbitmq_custom_queue_health_score &lt; 50<br>        for: 1m<br>        labels:<br>          severity: critical<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} health is CRITICAL&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has a critical health score of {{ $value }} (below 50). This indicates severe queue health issues requiring immediate attention. Check for consumer failures, high message accumulation, or processing bottlenecks.&quot;<br><br>      # Message Rate Alerts<br>      - alert: RabbitMQHighMessagePublishRate<br>        expr: rate(rabbitmq_custom_queue_message_publish_rate[5m]) &gt; 1000<br>        for: 2m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has high publish rate&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; is receiving messages at a very high rate ({{ $value }} msgs/sec). This may indicate a traffic spike or potential message flooding. Monitor queue depth and consumer processing rates.&quot;<br><br>      - alert: RabbitMQHighMessageDeliveryRate<br>        expr: rate(rabbitmq_custom_queue_message_deliver_rate[5m]) &gt; 1000<br>        for: 2m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has high delivery rate&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; is delivering messages at a very high rate ({{ $value }} msgs/sec). This may indicate high consumer activity or potential message processing issues. Monitor consumer health and processing success rates.&quot;<br><br>      # Message Processing Alerts<br>      - alert: RabbitMQHighMessageRedeliveryRate<br>        expr: rate(rabbitmq_custom_queue_message_redeliver_rate[5m]) &gt; 10<br>        for: 2m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has high redelivery rate&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has a high message redelivery rate ({{ $value }} msgs/sec). This indicates consumer processing failures or message acknowledgment issues. Check consumer error logs and processing logic.&quot;<br><br>      - alert: RabbitMQHighMessageRedeliveryRateCritical<br>        expr: rate(rabbitmq_custom_queue_message_redeliver_rate[5m]) &gt; 50<br>        for: 1m<br>        labels:<br>          severity: critical<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has CRITICAL redelivery rate&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has a critical message redelivery rate ({{ $value }} msgs/sec). This indicates severe consumer processing failures. Immediate investigation of consumer applications required.&quot;<br><br>      # Unacknowledged Messages Alerts<br>      - alert: RabbitMQHighUnacknowledgedMessages<br>        expr: rabbitmq_custom_queue_messages_unacknowledged &gt; 100<br>        for: 2m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has high unacknowledged messages&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has {{ $value }} unacknowledged messages. This indicates slow message processing or consumer acknowledgment issues. Check consumer processing speed and acknowledgment logic.&quot;<br><br>      - alert: RabbitMQCriticalUnacknowledgedMessages<br>        expr: rabbitmq_custom_queue_messages_unacknowledged &gt; 1000<br>        for: 1m<br>        labels:<br>          severity: critical<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has CRITICAL unacknowledged messages&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has {{ $value }} unacknowledged messages. This indicates severe consumer processing issues or consumer failures. Immediate consumer restart or scaling required.&quot;<br><br>      # Dead Letter Queue Alerts<br>      - alert: RabbitMQDeadLetterQueueDetected<br>        expr: rabbitmq_custom_queue_is_dead_letter == 1<br>        for: 0m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Dead Letter Queue detected: {{ $labels.queue_name }}&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; is identified as a dead letter queue. This is normal for dead letter queues, but monitor for message accumulation and ensure dead letter processing is working correctly.&quot;<br><br>      # Scrape Duration Alerts<br>      - alert: RabbitMQScrapeDurationHigh<br>        expr: rabbitmq_custom_scrape_duration_seconds &gt; 5<br>        for: 2m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ metrics scrape duration is high&quot;<br>          description: &quot;RabbitMQ metrics collection is taking {{ $value }} seconds, which is above the 5-second threshold. This may indicate RabbitMQ API performance issues or network latency. Monitor RabbitMQ Management API response times.&quot;<br><br>      - alert: RabbitMQScrapeDurationCritical<br>        expr: rabbitmq_custom_scrape_duration_seconds &gt; 10<br>        for: 1m<br>        labels:<br>          severity: critical<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ metrics scrape duration is CRITICAL&quot;<br>          description: &quot;RabbitMQ metrics collection is taking {{ $value }} seconds, which is critically high. This indicates severe RabbitMQ API performance issues or network problems. Check RabbitMQ server health and network connectivity.&quot;<br><br>      # Circuit Breaker Failure Count Alerts<br>      - alert: RabbitMQCircuitBreakerFailures<br>        expr: increase(rabbitmq_custom_circuit_breaker_failures_total[5m]) &gt; 5<br>        for: 1m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ circuit breaker failures detected&quot;<br>          description: &quot;{{ $value }} circuit breaker failures detected in the last 5 minutes. This indicates intermittent connectivity issues with RabbitMQ Management API. Monitor for circuit breaker state changes and RabbitMQ API availability.&quot;<br><br>      # Queue State Alerts<br>      - alert: RabbitMQQueueBlocked<br>        expr: rabbitmq_custom_queue_state{state=&quot;blocked&quot;} == 1<br>        for: 1m<br>        labels:<br>          severity: critical<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} is BLOCKED&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; is in BLOCKED state. This indicates the queue has been blocked due to memory pressure or other resource constraints. Check RabbitMQ memory usage and resource limits.&quot;<br><br>      # Consumer Capacity Alerts<br>      - alert: RabbitMQConsumerCapacityLow<br>        expr: rabbitmq_custom_queue_consumer_capacity &lt; 0.5<br>        for: 2m<br>        labels:<br>          severity: warning<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has low consumer capacity&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has consumer capacity of {{ $value }} (below 50%). This indicates insufficient consumer resources or consumer scaling issues. Consider scaling up consumers.&quot;<br><br>      - alert: RabbitMQConsumerCapacityCritical<br>        expr: rabbitmq_custom_queue_consumer_capacity &lt; 0.2<br>        for: 1m<br>        labels:<br>          severity: critical<br>          service: rabbitmq<br>        annotations:<br>          summary: &quot;RabbitMQ Queue {{ $labels.queue_name }} has CRITICAL consumer capacity&quot;<br>          description: &quot;Queue &#39;{{ $labels.queue_name }}&#39; in vhost &#39;{{ $labels.vhost }}&#39; has critically low consumer capacity of {{ $value }} (below 20%). This indicates severe consumer resource issues. Immediate consumer scaling required.&quot;</pre><p>The custom exporter transformed our RabbitMQ monitoring from reactive troubleshooting to proactive queue management. Instead of spending time figuring out what’s wrong, we can quickly identify which queues need attention and why.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=53fb0493a634" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Creating Bitbucket Pipe for Bitbucket Pipelines: From ECR to Helm in One Go]]></title>
            <link>https://medium.com/@jimoh_abdol/creating-bitbucket-pipe-for-bitbucket-pipelines-from-ecr-to-helm-in-one-go-2952ab2197d9?source=rss-7f144da93169------2</link>
            <guid isPermaLink="false">https://medium.com/p/2952ab2197d9</guid>
            <dc:creator><![CDATA[Jimoh Abdulrahman]]></dc:creator>
            <pubDate>Sun, 13 Jul 2025 07:05:48 GMT</pubDate>
            <atom:updated>2025-07-13T07:05:48.385Z</atom:updated>
            <content:encoded><![CDATA[<h3>The Problem That Started It All</h3><p>A few days ago, a colleague introduced me to his friend, who contacted me with a familiar DevOps challenge. Their team had adopted ArgoCD for GitOps-based deployments but faced difficulties with their CI/CD pipeline. They required a solution similar to GitHub’s reusable workflow in Bitbucket, specifically for their GitOps process: building Docker images, pushing them to Amazon ECR, and updating Helm chart values in their GitOps repository, allowing ArgoCD to recognise the changes.</p><p>As a DevOps engineer passionate about mentorship and automation, I saw this as more than just a technical challenge; it was an opportunity to explore Bitbucket’s lesser-known but powerful Pipes feature and share it for the benefit of others.</p><h3>Why GitOps + Bitbucket Pipes?</h3><p>Modern Kubernetes deployments increasingly follow the GitOps pattern, where:</p><ul><li>Application code lives in one repository</li><li>Deployment manifests and Helm charts live in a separate GitOps repository</li><li>ArgoCD watches the GitOps repository for changes</li><li>Deployments happen automatically when manifests are updated</li></ul><p>While GitHub has its reusable workflows, Bitbucket offers something equally powerful: Pipes. Think of pipes as pre-built, reusable components that you can drop into your pipeline with minimal configuration. They’re Docker containers that perform specific tasks, making your bitbucket-pipelines.yml cleaner and your GitOps deployments more reliable.</p><p>After diving into Atlassian’s pipe <a href="https://support.atlassian.com/bitbucket-cloud/docs/write-a-pipe-for-bitbucket-pipelines/">documentation</a>, I realised this was the perfect opportunity to build something that could seamlessly integrate with GitOps workflows and began architecting a solution that could:</p><ul><li>Build and push Docker images to AWS ECR</li><li>Deploy Helm charts to Kubernetes</li><li>Be reusable across multiple Bitbucket repositories</li></ul><h3>What I Built: Docker Build, Push to AWS ECR and GitOps Helm Update Pipe</h3><p>The result is an open-source Bitbucket pipe that handles the complete Docker-to-GitOps pipeline, perfectly complementing ArgoCD deployments:</p><p>GitHub Repository: <a href="https://github.com/jimohabdol/ecr-build-helm-update-pipe.git">ecr-build-helm-update-pipe</a></p><h3>Step-by-Step: Building Bitbucket Pipe</h3><p>Let me walk you through the complete process of building this production-ready pipe, following Atlassian’s official guidelines.</p><h4>Setting Up the Repository Structure</h4><p>A pipe is made up of a few different files: A script, or binary, the code that performs the task. A Dockerfile, which tells us how to build the Docker container that runs your script.</p><p>First, create a new repository on Bitbucket with the following structure:</p><pre>ecr-build-helm-update-pipe/<br>├── Dockerfile              # Container definition<br>├── pipe.sh                 # Main script<br>├── pipe.yml               # Metadata (optional but recommended)<br>├── README.md              # Documentation<br>├── bitbucket-pipelines.yml # CI/CD for the pipe itself<br>└── validate-pipe.sh        # Test files</pre><h4>Creating the Core Script (pipe.sh)</h4><p>The heart of the pipe ispipe.sh script. This script handles:</p><ul><li>Docker image building and pushing to ECR</li><li>Cloning the GitOps repository</li><li>Updating Helm values</li><li>Committing and pushing changes</li></ul><pre>#!/bin/bash<br><br>set -euo pipefail<br><br>if [[ &quot;${DEBUG:-false}&quot; == &quot;true&quot; ]]; then<br>    set -x<br>fi<br><br>RED=&#39;\033[0;31m&#39;<br>GREEN=&#39;\033[0;32m&#39;<br>YELLOW=&#39;\033[1;33m&#39;<br>BLUE=&#39;\033[0;34m&#39;<br>NC=&#39;\033[0m&#39;<br><br>log_info() {<br>    echo -e &quot;${BLUE}[INFO]${NC} $1&quot;<br>}<br><br>log_success() {<br>    echo -e &quot;${GREEN}[SUCCESS]${NC} $1&quot;<br>}<br><br>log_warning() {<br>    echo -e &quot;${YELLOW}[WARNING]${NC} $1&quot;<br>}<br><br>log_error() {<br>    echo -e &quot;${RED}[ERROR]${NC} $1&quot;<br>}<br><br>validate_variables() {<br>    log_info &quot;Validating required variables...&quot;<br>    <br>    local required_vars=(<br>        &quot;ECR_REPO&quot;<br>        &quot;HELM_PATH&quot;<br>        &quot;HELM_REPO&quot;<br>        &quot;AWS_ACCESS_KEY_ID&quot;<br>        &quot;AWS_SECRET_ACCESS_KEY&quot;<br>        &quot;ECR_REGISTRY&quot;<br>        &quot;TOKEN&quot;<br>    )<br>    <br>    local missing_vars=()<br>    <br>    for var in &quot;${required_vars[@]}&quot;; do<br>        if [[ -z &quot;${!var:-}&quot; ]]; then<br>            missing_vars+=(&quot;$var&quot;)<br>        fi<br>    done<br>    <br>    if [[ ${#missing_vars[@]} -gt 0 ]]; then<br>        log_error &quot;Missing required variables: ${missing_vars[*]}&quot;<br>        exit 1<br>    fi<br>    <br>    log_success &quot;All required variables are present&quot;<br>}<br><br>assume_role() {<br>    log_info &quot;Assuming AWS role...&quot;<br>    <br>    if [[ &quot;${ASSUME_ROLE_ENABLED:-false}&quot; != &quot;true&quot; ]]; then<br>        log_info &quot;Assume role is disabled, skipping&quot;<br>        return 0<br>    fi<br>    <br>    if [[ -z &quot;${ASSUME_ROLE_ARN:-}&quot; ]]; then<br>        log_error &quot;ASSUME_ROLE_ARN is required when ASSUME_ROLE_ENABLED is true&quot;<br>        exit 1<br>    fi<br>    <br>    local session_name=&quot;${ASSUME_ROLE_SESSION_NAME:-bitbucket-ecr-session}&quot;<br>    local external_id_param=&quot;&quot;<br>    <br>    if [[ -n &quot;${ASSUME_ROLE_EXTERNAL_ID:-}&quot; ]]; then<br>        external_id_param=&quot;--external-id ${ASSUME_ROLE_EXTERNAL_ID}&quot;<br>    fi<br>    <br>    log_info &quot;Assuming role: ${ASSUME_ROLE_ARN}&quot;<br>    log_info &quot;Session name: ${session_name}&quot;<br>    <br>    local creds_output<br>    if ! creds_output=$(aws sts assume-role \<br>        --role-arn &quot;${ASSUME_ROLE_ARN}&quot; \<br>        --role-session-name &quot;${session_name}&quot; \<br>        ${external_id_param} \<br>        --output json 2&gt;&amp;1); then<br>        log_error &quot;Failed to assume role: ${ASSUME_ROLE_ARN}&quot;<br>        log_error &quot;Error: ${creds_output}&quot;<br>        exit 1<br>    fi<br>    <br>    if ! command -v jq &gt;/dev/null 2&gt;&amp;1; then<br>        log_error &quot;jq is required for parsing assume-role response&quot;<br>        exit 1<br>    fi<br>    <br>    local access_key_id<br>    local secret_access_key<br>    local session_token<br>    <br>    if ! access_key_id=$(echo &quot;$creds_output&quot; | jq -r &#39;.Credentials.AccessKeyId&#39;); then<br>        log_error &quot;Failed to extract AccessKeyId from assume-role response&quot;<br>        exit 1<br>    fi<br>    <br>    if ! secret_access_key=$(echo &quot;$creds_output&quot; | jq -r &#39;.Credentials.SecretAccessKey&#39;); then<br>        log_error &quot;Failed to extract SecretAccessKey from assume-role response&quot;<br>        exit 1<br>    fi<br>    <br>    if ! session_token=$(echo &quot;$creds_output&quot; | jq -r &#39;.Credentials.SessionToken&#39;); then<br>        log_error &quot;Failed to extract SessionToken from assume-role response&quot;<br>        exit 1<br>    fi<br>    <br>    # Export the new credentials<br>    export AWS_ACCESS_KEY_ID=&quot;$access_key_id&quot;<br>    export AWS_SECRET_ACCESS_KEY=&quot;$secret_access_key&quot;<br>    export AWS_SESSION_TOKEN=&quot;$session_token&quot;<br>    <br>    log_success &quot;Successfully assumed role and updated credentials&quot;<br>    <br>    # Log credential info (without exposing sensitive data)<br>    log_info &quot;Access Key ID: ${AWS_ACCESS_KEY_ID:0:10}...&quot;<br>    log_info &quot;Session Token: ${AWS_SESSION_TOKEN:0:20}...&quot;<br>}<br><br>setup_aws_credentials() {<br>    log_info &quot;Setting up AWS credentials...&quot;<br>    <br>    aws configure set aws_access_key_id &quot;${AWS_ACCESS_KEY_ID}&quot;<br>    aws configure set aws_secret_access_key &quot;${AWS_SECRET_ACCESS_KEY}&quot;<br>    aws configure set region &quot;${AWS_REGION:-us-east-1}&quot;<br>    <br>    if [[ -n &quot;${AWS_SESSION_TOKEN:-}&quot; ]]; then<br>        aws configure set aws_session_token &quot;${AWS_SESSION_TOKEN}&quot;<br>        log_info &quot;Session token configured for assume-role&quot;<br>    fi<br>    <br>    log_success &quot;AWS credentials configured&quot;<br>}<br><br>ecr_login() {<br>    log_info &quot;Logging into ECR...&quot;<br>    <br>    if ! aws ecr get-login-password --region &quot;${AWS_REGION:-us-east-1}&quot; | docker login --username AWS --password-stdin &quot;${ECR_REGISTRY}&quot;; then<br>        log_error &quot;Failed to login to ECR&quot;<br>        exit 1<br>    fi<br>    <br>    log_success &quot;Successfully logged into ECR&quot;<br>}<br><br>build_and_push() {<br>    log_info &quot;Building and pushing Docker image for ${ECR_REPO}...&quot;<br>    <br>    local short_sha=&quot;${IMAGE_TAG:-${BITBUCKET_COMMIT:0:6}}&quot;<br>    log_info &quot;Short SHA: ${short_sha}&quot;<br>    <br>    local max_retries=&quot;${MAX_BUILD_RETRIES:-5}&quot;<br>    local retries=0<br>    local dockerfile_path=&quot;${DOCKERFILE_PATH:-Dockerfile}&quot;<br>    <br>    if [[ ! -f &quot;${dockerfile_path}&quot; ]]; then<br>        log_error &quot;Dockerfile not found at ${dockerfile_path}&quot;<br>        exit 1<br>    fi<br>    <br>    while [[ ${retries} -lt ${max_retries} ]]; do<br>        log_info &quot;Build attempt $((retries + 1))/${max_retries}...&quot;<br>        <br>        # Build the image<br>        if docker build \<br>            --cache-from &quot;${ECR_REGISTRY}/${ECR_REPO}:latest&quot; \<br>            --tag &quot;${ECR_REGISTRY}/${ECR_REPO}:latest&quot; \<br>            --tag &quot;${ECR_REGISTRY}/${ECR_REPO}:${short_sha}&quot; \<br>            -f &quot;${dockerfile_path}&quot; .; then<br>            <br>            log_success &quot;Docker build completed successfully&quot;<br>            <br>            if docker push &quot;${ECR_REGISTRY}/${ECR_REPO}:${short_sha}&quot; &amp;&amp; \<br>               docker push &quot;${ECR_REGISTRY}/${ECR_REPO}:latest&quot;; then<br>                <br>                log_success &quot;Docker push completed successfully&quot;<br>                <br>                echo &quot;Image: ${ECR_REGISTRY}/${ECR_REPO}:${short_sha}&quot; &gt; docker-image-info.txt<br>                echo &quot;Latest: ${ECR_REGISTRY}/${ECR_REPO}:latest&quot; &gt;&gt; docker-image-info.txt<br>                echo &quot;Build Date: $(date)&quot; &gt;&gt; docker-image-info.txt<br>                echo &quot;Commit: ${BITBUCKET_COMMIT}&quot; &gt;&gt; docker-image-info.txt<br>                <br>                return 0<br>            else<br>                log_error &quot;Docker push failed&quot;<br>            fi<br>        else<br>            log_error &quot;Docker build failed&quot;<br>        fi<br>        <br>        retries=$((retries + 1))<br>        if [[ ${retries} -lt ${max_retries} ]]; then<br>            log_warning &quot;Retrying in 10 seconds...&quot;<br>            sleep 10<br>        fi<br>    done<br>    <br>    log_error &quot;Build and push failed after ${max_retries} attempts&quot;<br>    exit 1<br>}<br><br>update_helm_values() {<br>    log_info &quot;Updating Helm values...&quot;<br>    <br>    local short_sha=&quot;${IMAGE_TAG:-${BITBUCKET_COMMIT:0:6}}&quot;<br>    local max_retries=&quot;${MAX_HELM_RETRIES:-3}&quot;<br>    local retries=0<br>    local helm_branch=&quot;${HELM_BRANCH:-main}&quot;<br>    <br>    while [[ ${retries} -lt ${max_retries} ]]; do<br>        log_info &quot;Helm update attempt $((retries + 1))/${max_retries}...&quot;<br>        <br>        rm -rf helm-chart<br>        <br>        log_info &quot;Cloning repository: ${HELM_REPO}&quot;<br>        log_info &quot;Using branch: ${helm_branch}&quot;<br>        log_info &quot;Token length: ${#TOKEN}&quot;<br>        <br>        if ! git clone -b &quot;${helm_branch}&quot; &quot;https://x-token-auth:${TOKEN}@${HELM_REPO}&quot; helm-chart; then<br>            log_warning &quot;Primary authentication failed, trying alternative method...&quot;<br>            <br>            if ! git clone -b &quot;${helm_branch}&quot; &quot;https://${TOKEN}@${HELM_REPO}&quot; helm-chart; then<br>                log_error &quot;Failed to clone helm repository with both methods&quot;<br>                log_error &quot;Repository: ${HELM_REPO}&quot;<br>                log_error &quot;Branch: ${helm_branch}&quot;<br>                retries=$((retries + 1))<br>                continue<br>            else<br>                log_info &quot;Successfully cloned using alternative authentication&quot;<br>            fi<br>        else<br>            log_info &quot;Successfully cloned using primary authentication&quot;<br>        fi<br>        <br>        if ! cd helm-chart; then<br>            log_error &quot;Failed to enter helm-chart directory&quot;<br>            retries=$((retries + 1))<br>            continue<br>        fi<br>        <br>        if [[ ! -f &quot;${HELM_PATH}&quot; ]]; then<br>            log_error &quot;Helm values file not found at ${HELM_PATH}&quot;<br>            cd .. || log_warning &quot;Failed to return to parent directory&quot;<br>            retries=$((retries + 1))<br>            continue<br>        fi<br>        <br>        log_info &quot;Current helm values file content:&quot;<br>        cat &quot;${HELM_PATH}&quot;<br>        <br>        local backup_file=&quot;${HELM_PATH}.backup.$$&quot;<br>        cp &quot;${HELM_PATH}&quot; &quot;${backup_file}&quot;<br>        <br>        local update_mode=&quot;${HELM_UPDATE_MODE:-auto}&quot;<br>        local updated=false<br>        <br>        if [[ -z &quot;${short_sha}&quot; ]]; then<br>            log_error &quot;Short SHA is empty - cannot update image tag&quot;<br>            rm -f &quot;${backup_file}&quot;<br>            cd .. || log_warning &quot;Failed to return to parent directory&quot;<br>            retries=$((retries + 1))<br>            continue<br>        fi<br>        <br>        log_info &quot;Using HELM_UPDATE_MODE: ${update_mode}&quot;<br>        log_info &quot;Updating to image tag: ${short_sha}&quot;<br>        <br>        case &quot;${update_mode}&quot; in<br>            &quot;tag-only&quot;)<br>                log_info &quot;Mode: Update only image.tag field&quot;<br>                if sed -i &quot;s|^[[:space:]]\{1,\}tag:[[:space:]]*.*|  tag: \&quot;${short_sha}\&quot;|&quot; &quot;${HELM_PATH}&quot; 2&gt;/dev/null; then<br>                    if ! cmp -s &quot;${HELM_PATH}&quot; &quot;${backup_file}&quot;; then<br>                        updated=true<br>                        log_info &quot;Successfully updated using tag-only format&quot;<br>                    else<br>                        log_warning &quot;Tag field not found or no changes made in tag-only mode&quot;<br>                    fi<br>                else<br>                    log_warning &quot;Sed command failed in tag-only mode&quot;<br>                fi<br>                ;;<br>                <br>            &quot;repository-and-tag&quot;)<br>                log_info &quot;Mode: Update both image.repository and image.tag fields&quot;<br>                if sed -i &quot;s|^[[:space:]]\{1,\}repository:[[:space:]]*.*|  repository: ${ECR_REGISTRY}/${ECR_REPO}|&quot; &quot;${HELM_PATH}&quot; 2&gt;/dev/null &amp;&amp; \<br>                   sed -i &quot;s|^[[:space:]]\{1,\}tag:[[:space:]]*.*|  tag: \&quot;${short_sha}\&quot;|&quot; &quot;${HELM_PATH}&quot; 2&gt;/dev/null; then<br>                    if ! cmp -s &quot;${HELM_PATH}&quot; &quot;${backup_file}&quot;; then<br>                        updated=true<br>                        log_info &quot;Successfully updated using repository and tag format&quot;<br>                    else<br>                        log_warning &quot;Repository/tag fields not found or no changes made in repository-and-tag mode&quot;<br>                    fi<br>                else<br>                    log_warning &quot;Sed command failed in repository-and-tag mode&quot;<br>                fi<br>                ;;<br>                <br>            &quot;image-line&quot;)<br>                log_info &quot;Mode: Update entire image line (single line format)&quot;<br>                if sed -i &quot;s|^[[:space:]]*image:[[:space:]]*.*|image: ${ECR_REGISTRY}/${ECR_REPO}:${short_sha}|&quot; &quot;${HELM_PATH}&quot; 2&gt;/dev/null; then<br>                    if ! cmp -s &quot;${HELM_PATH}&quot; &quot;${backup_file}&quot;; then<br>                        updated=true<br>                        log_info &quot;Successfully updated using simple image format&quot;<br>                    else<br>                        log_warning &quot;Image line not found or no changes made in image-line mode&quot;<br>                    fi<br>                else<br>                    log_warning &quot;Sed command failed in image-line mode&quot;<br>                fi<br>                ;;<br>                <br>            &quot;auto&quot;|*)<br>                log_info &quot;Mode: Auto-detect (try tag-only first, then fallback)&quot;<br>                <br>                log_info &quot;Trying to update only the tag field...&quot;<br>                if sed -i &quot;s|^[[:space:]]\{1,\}tag:[[:space:]]*.*|  tag: \&quot;${short_sha}\&quot;|&quot; &quot;${HELM_PATH}&quot; 2&gt;/dev/null; then<br>                    if ! cmp -s &quot;${HELM_PATH}&quot; &quot;${backup_file}&quot;; then<br>                        updated=true<br>                        log_info &quot;Successfully updated using tag-only format&quot;<br>                    else<br>                        log_info &quot;Tag field found but no changes made&quot;<br>                    fi<br>                else<br>                    log_info &quot;Tag field not found or sed failed&quot;<br>                fi<br>                <br>                if ! $updated; then<br>                    log_info &quot;Tag-only update failed, trying repository + tag update...&quot;<br>                    cp &quot;${backup_file}&quot; &quot;${HELM_PATH}&quot;<br>                    <br>                    if sed -i &quot;s|^[[:space:]]\{1,\}repository:[[:space:]]*.*|  repository: ${ECR_REGISTRY}/${ECR_REPO}|&quot; &quot;${HELM_PATH}&quot; 2&gt;/dev/null &amp;&amp; \<br>                       sed -i &quot;s|^[[:space:]]\{1,\}tag:[[:space:]]*.*|  tag: \&quot;${short_sha}\&quot;|&quot; &quot;${HELM_PATH}&quot; 2&gt;/dev/null; then<br>                        if ! cmp -s &quot;${HELM_PATH}&quot; &quot;${backup_file}&quot;; then<br>                            updated=true<br>                            log_info &quot;Successfully updated using repository and tag format&quot;<br>                        else<br>                            log_info &quot;Repository/tag fields found but no changes made&quot;<br>                        fi<br>                    else<br>                        log_info &quot;Repository/tag fields not found or sed failed&quot;<br>                    fi<br>                fi<br>                <br>                if ! $updated; then<br>                    log_info &quot;Structured update failed, trying simple image format...&quot;<br>                    cp &quot;${backup_file}&quot; &quot;${HELM_PATH}&quot;<br>                    <br>                    if sed -i &quot;s|^[[:space:]]*image:[[:space:]]*.*|image: ${ECR_REGISTRY}/${ECR_REPO}:${short_sha}|&quot; &quot;${HELM_PATH}&quot; 2&gt;/dev/null; then<br>                        if ! cmp -s &quot;${HELM_PATH}&quot; &quot;${backup_file}&quot;; then<br>                            updated=true<br>                            log_info &quot;Successfully updated using simple image format&quot;<br>                        else<br>                            log_info &quot;Image line found but no changes made&quot;<br>                        fi<br>                    else<br>                        log_info &quot;Image line not found or sed failed&quot;<br>                    fi<br>                fi<br>                ;;<br>        esac<br>        <br>        if ! $updated; then<br>            log_error &quot;Failed to update image tag in helm values - no matching pattern found&quot;<br>            rm -f &quot;${backup_file}&quot;<br>            cd .. || log_warning &quot;Failed to return to parent directory&quot;<br>            retries=$((retries + 1))<br>            continue<br>        fi<br>        <br>        log_info &quot;Updated helm values file content:&quot;<br>        cat &quot;${HELM_PATH}&quot;<br><br>        log_info &quot;Changes made to ${HELM_PATH}:&quot;<br>        if command -v diff &gt;/dev/null 2&gt;&amp;1; then<br>            diff -u &quot;${backup_file}&quot; &quot;${HELM_PATH}&quot; &amp;&amp; log_info &quot;No differences found (unexpected)&quot; || log_info &quot;✅ Changes detected and applied&quot;<br>        else<br>            log_info &quot;Diff not available, showing updated tag lines:&quot;<br>            grep -n &quot;tag:&quot; &quot;${HELM_PATH}&quot; || log_info &quot;No tag field found in updated file&quot;<br>        fi<br>        <br>        rm -f &quot;${backup_file}&quot;<br>        <br>        git config user.name &quot;${GIT_USER_NAME:-Bitbucket Pipeline}&quot;<br>        git config user.email &quot;${GIT_USER_EMAIL:-devops@yourcompany.com}&quot;<br><br>        git add .<br>        <br>        if git diff --cached --quiet; then<br>            log_warning &quot;No changes detected in helm values&quot;<br>            cd .. || log_warning &quot;Failed to return to parent directory&quot;<br>            return 0<br>        fi<br>        <br>        local commit_message=&quot;Update ${ECR_REPO} image tag to ${short_sha}<br><br>Repository: ${ECR_REPO}<br>Image: ${ECR_REGISTRY}/${ECR_REPO}:${short_sha}<br>Commit: ${BITBUCKET_COMMIT}<br>Pipeline: ${BITBUCKET_BUILD_NUMBER:-unknown}&quot;<br>        <br>        if ! git commit -m &quot;${commit_message}&quot;; then<br>            log_error &quot;Failed to commit changes&quot;<br>            cd .. || log_warning &quot;Failed to return to parent directory&quot;<br>            retries=$((retries + 1))<br>            continue<br>        fi<br>        <br>        if ! git pull --rebase origin &quot;${helm_branch}&quot;; then<br>            log_error &quot;Failed to pull and rebase&quot;<br>            cd .. || log_warning &quot;Failed to return to parent directory&quot;<br>            retries=$((retries + 1))<br>            continue<br>        fi<br>        <br>        if git push origin &quot;${helm_branch}&quot;; then<br>            log_success &quot;Successfully updated helm values&quot;<br>            cd .. || log_warning &quot;Failed to return to parent directory&quot;<br>            return 0<br>        else<br>            log_error &quot;Failed to push changes&quot;<br>            cd .. || log_warning &quot;Failed to return to parent directory&quot;<br>        fi<br>        <br>        retries=$((retries + 1))<br>        if [[ ${retries} -lt ${max_retries} ]]; then<br>            log_warning &quot;Retrying helm update in 5 seconds...&quot;<br>            sleep 5<br>        fi<br>    done<br>    <br>    log_error &quot;Helm update failed after ${max_retries} attempts&quot;<br>    exit 1<br>}<br><br>main() {<br>    log_info &quot;Starting ECR Build and Helm Update Pipe&quot;<br>    log_info &quot;ECR Repository: ${ECR_REPO}&quot;<br>    log_info &quot;Dockerfile Path: ${DOCKERFILE_PATH:-Dockerfile}&quot;<br>    log_info &quot;Helm Path: ${HELM_PATH}&quot;<br>    log_info &quot;Helm Branch: ${HELM_BRANCH:-main}&quot;<br>    <br>    validate_variables<br>    assume_role<br>    setup_aws_credentials<br>    ecr_login<br>    build_and_push<br>    update_helm_values<br>    <br>    log_success &quot;Pipeline completed successfully!&quot;<br>}<br><br>if [[ &quot;${PIPE_TEST_MODE:-false}&quot; != &quot;true&quot; ]]; then<br>    main &quot;$@&quot;<br>else<br>    log_info &quot;Running in test mode - skipping main execution&quot;<br>fi </pre><h4>Creating the Dockerfile</h4><p>The Dockerfile defines how to build the container that runs the pipe.sh script:</p><pre>FROM atlassian/pipelines-awscli:latest<br><br># Metadata<br>LABEL maintainer=&quot;jimoh abdulrahman&quot;<br>LABEL version=&quot;1.0.0&quot;<br>LABEL description=&quot;ECR Build and Helm Update Pipe for Bitbucket Pipelines&quot;<br><br>RUN apk update &amp;&amp; apk add --no-cache \<br>    wget \<br>    jq \<br>    sed \<br>    grep \<br>    git \<br>    ca-certificates \<br>    bash \<br>    tar \<br>    curl<br><br><br>RUN wget -O /tmp/docker.tgz https://download.docker.com/linux/static/stable/x86_64/docker-24.0.6.tgz &amp;&amp; \<br>    tar -xzf /tmp/docker.tgz -C /tmp &amp;&amp; \<br>    mv /tmp/docker/docker /usr/local/bin/docker &amp;&amp; \<br>    chmod +x /usr/local/bin/docker &amp;&amp; \<br>    rm -rf /tmp/docker.tgz /tmp/docker<br><br>RUN docker --version<br><br>WORKDIR /opt/pipe<br><br>COPY pipe.sh /opt/pipe/pipe.sh<br><br>RUN chmod +x /opt/pipe/pipe.sh<br><br>RUN adduser -D -s /bin/bash -u 1000 pipeuser || true<br><br>USER root<br><br>HEALTHCHECK --interval=60s --timeout=30s --start-period=10s --retries=2 \<br>    CMD command -v aws &amp;&amp; command -v docker &amp;&amp; command -v git<br><br>ENTRYPOINT [&quot;/opt/pipe/pipe.sh&quot;] </pre><h4>Setting Up CI/CD for Pipe</h4><p>Create a bitbucket-pipelines.yml file to automate building and publishing the pipe:</p><pre>image: atlassian/default-image:4<br><br>definitions:<br>  services:<br>    docker:<br>      memory: 2048<br><br>pipelines:<br>  branches:<br>    main:<br>      - step:<br>          name: Build and Push Pipe Image<br>          image: atlassian/pipelines-awscli:latest<br>          services:<br>            - docker<br>          size: 2x<br>          script:<br>            - echo &quot;Building ECR Build and Helm Update Pipe&quot;<br>            <br>            - |<br>              if [ -n &quot;$BITBUCKET_TAG&quot; ]; then<br>                export VERSION=&quot;$BITBUCKET_TAG&quot;<br>              elif [ -n &quot;$BITBUCKET_COMMIT&quot; ]; then<br>                export VERSION=&quot;${BITBUCKET_COMMIT:0:6}&quot;<br>              else<br>                export VERSION=&quot;manual-$(date +%s)&quot;<br>              fi<br>              echo &quot;Version: $VERSION&quot;<br>            <br>            - |<br>              if [[ -z &quot;$AWS_ACCESS_KEY_ID&quot; || -z &quot;$AWS_SECRET_ACCESS_KEY&quot; || -z &quot;$ECR_REGISTRY&quot; ]]; then<br>                echo &quot;Error: Required AWS variables are not set&quot;<br>                exit 1<br>              fi<br>              if [[ &quot;${ASSUME_ROLE_ENABLED:-false}&quot; == &quot;true&quot; &amp;&amp; -z &quot;$ASSUME_ROLE_ARN&quot; ]]; then<br>                echo &quot;Error: ASSUME_ROLE_ARN is required when ASSUME_ROLE_ENABLED is true&quot;<br>                exit 1<br>              fi<br>            <br>            - aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID<br>            - aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY<br>            - aws configure set region us-east-1<br>            <br>            - |<br>              if [[ &quot;${ASSUME_ROLE_ENABLED:-false}&quot; == &quot;true&quot; ]]; then<br>                echo &quot;Assuming role: $ASSUME_ROLE_ARN&quot;<br>                <br>                # Assume the role and get temporary credentials<br>                CREDS=$(aws sts assume-role \<br>                  --role-arn &quot;$ASSUME_ROLE_ARN&quot; \<br>                  --role-session-name &quot;bitbucket-pipe-build-session&quot; \<br>                  ${ASSUME_ROLE_EXTERNAL_ID:+--external-id &quot;$ASSUME_ROLE_EXTERNAL_ID&quot;} \<br>                  --output json)<br>                <br>                # Extract credentials<br>                export AWS_ACCESS_KEY_ID=$(echo $CREDS | jq -r &#39;.Credentials.AccessKeyId&#39;)<br>                export AWS_SECRET_ACCESS_KEY=$(echo $CREDS | jq -r &#39;.Credentials.SecretAccessKey&#39;)<br>                export AWS_SESSION_TOKEN=$(echo $CREDS | jq -r &#39;.Credentials.SessionToken&#39;)<br>                <br>                # Update AWS CLI configuration with new credentials<br>                aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID<br>                aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY<br>                aws configure set aws_session_token $AWS_SESSION_TOKEN<br>                <br>                echo &quot;Successfully assumed role and updated credentials&quot;<br>              else<br>                echo &quot;Assume role is disabled, using direct credentials&quot;<br>              fi<br>            <br>            - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REGISTRY<br>            <br>            - export DOCKER_BUILDKIT=1<br>            - |<br>              docker build --pull \<br>                --cache-from $ECR_REGISTRY/ecr-build-helm-update-pipe:latest \<br>                -t $ECR_REGISTRY/ecr-build-helm-update-pipe:$VERSION \<br>                -t $ECR_REGISTRY/ecr-build-helm-update-pipe:latest \<br>                .<br>            <br>            - |<br>              echo &quot;Pushing images...&quot;<br>              docker push $ECR_REGISTRY/ecr-build-helm-update-pipe:$VERSION &amp;<br>              docker push $ECR_REGISTRY/ecr-build-helm-update-pipe:latest &amp;<br>              wait<br>              echo &quot;All images pushed successfully&quot;<br>            <br>            - |<br>              {<br>                echo &quot;Pipe Image: $ECR_REGISTRY/ecr-build-helm-update-pipe:$VERSION&quot;<br>                echo &quot;Latest: $ECR_REGISTRY/ecr-build-helm-update-pipe:latest&quot;<br>                echo &quot;Build Date: $(date)&quot;<br>                echo &quot;Commit: $BITBUCKET_COMMIT&quot;<br>                echo &quot;Pipeline: $BITBUCKET_BUILD_NUMBER&quot;<br>              } &gt; pipe-image-info.txt<br>            <br>            - echo &quot;Testing pipe image...&quot;<br>            - docker run --rm $ECR_REGISTRY/ecr-build-helm-update-pipe:$VERSION /bin/bash -c &quot;command -v aws &amp;&amp; command -v docker &amp;&amp; command -v git&quot; || echo &quot;Pipe ready for use&quot;<br>            <br>          artifacts:<br>            - pipe-image-info.txt<br><br>  tags:<br>    v*:<br>      - step:<br>          name: Release Pipe Version<br>          image: atlassian/pipelines-awscli:latest<br>          services:<br>            - docker<br>          size: 2x<br>          script:<br>            - echo &quot;Building and releasing ECR Build and Helm Update Pipe version $BITBUCKET_TAG&quot;<br>            <br>            - aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID<br>            - aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY<br>            - aws configure set region us-east-1<br>            <br>            - |<br>              if [[ &quot;${ASSUME_ROLE_ENABLED:-false}&quot; == &quot;true&quot; ]]; then<br>                echo &quot;Assuming role: $ASSUME_ROLE_ARN&quot;<br>                <br>                # Assume the role and get temporary credentials<br>                CREDS=$(aws sts assume-role \<br>                  --role-arn &quot;$ASSUME_ROLE_ARN&quot; \<br>                  --role-session-name &quot;bitbucket-pipe-release-session&quot; \<br>                  ${ASSUME_ROLE_EXTERNAL_ID:+--external-id &quot;$ASSUME_ROLE_EXTERNAL_ID&quot;} \<br>                  --output json)<br>                <br>                # Extract credentials<br>                export AWS_ACCESS_KEY_ID=$(echo $CREDS | jq -r &#39;.Credentials.AccessKeyId&#39;)<br>                export AWS_SECRET_ACCESS_KEY=$(echo $CREDS | jq -r &#39;.Credentials.SecretAccessKey&#39;)<br>                export AWS_SESSION_TOKEN=$(echo $CREDS | jq -r &#39;.Credentials.SessionToken&#39;)<br>                <br>                # Update AWS CLI configuration with new credentials<br>                aws configure set aws_access_key_id $AWS_ACCESS_KEY_ID<br>                aws configure set aws_secret_access_key $AWS_SECRET_ACCESS_KEY<br>                aws configure set aws_session_token $AWS_SESSION_TOKEN<br>                <br>                echo &quot;Successfully assumed role and updated credentials&quot;<br>              else<br>                echo &quot;Assume role is disabled, using direct credentials&quot;<br>              fi<br>            <br>            # Login to ECR<br>            - aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin $ECR_REGISTRY<br>            <br>            - docker build -t $ECR_REGISTRY/ecr-build-helm-update-pipe:$BITBUCKET_TAG .<br>            - docker build -t $ECR_REGISTRY/ecr-build-helm-update-pipe:latest .<br>            <br>            - docker push $ECR_REGISTRY/ecr-build-helm-update-pipe:$BITBUCKET_TAG<br>            - docker push $ECR_REGISTRY/ecr-build-helm-update-pipe:latest<br>            <br>            - echo &quot;# Release $BITBUCKET_TAG&quot; &gt; release-notes.md<br>            - echo &quot;&quot; &gt;&gt; release-notes.md<br>            - echo &quot;## Changes&quot; &gt;&gt; release-notes.md<br>            - echo &quot;- See commit history for detailed changes&quot; &gt;&gt; release-notes.md<br>            - echo &quot;&quot; &gt;&gt; release-notes.md<br>            - echo &quot;## Docker Image&quot; &gt;&gt; release-notes.md<br>            - echo &quot;\`\`\`&quot; &gt;&gt; release-notes.md<br>            - echo &quot;image - $ECR_REGISTRY/ecr-build-helm-update-pipe:$BITBUCKET_TAG&quot; &gt;&gt; release-notes.md<br>            - echo &quot;\`\`\`&quot; &gt;&gt; release-notes.md<br>            <br>          artifacts:<br>            - release-notes.md<br><br>  custom:<br>    test-pipe:<br>      - step:<br>          name: Test Pipe Functionality<br>          image: atlassian/pipelines-awscli:latest<br>          services:<br>            - docker<br>          script:<br>            - echo &quot;Testing pipe functionality...&quot;<br>            <br>            - export DOCKER_BUILDKIT=1<br>            - docker build -t test-pipe:latest .<br>            <br>            - echo &quot;Basic validation&quot;<br>            - docker run --rm -e PIPE_TEST_MODE=true test-pipe:latest /bin/bash -c &quot;echo &#39;Basic validation test passed&#39;&quot;<br>            <br>            - echo &quot;Tool availability&quot;<br>            - docker run --rm -e PIPE_TEST_MODE=true test-pipe:latest aws --version<br>            - docker run --rm -e PIPE_TEST_MODE=true test-pipe:latest docker --version<br>            - docker run --rm -e PIPE_TEST_MODE=true test-pipe:latest git --version<br>            - docker run --rm -e PIPE_TEST_MODE=true test-pipe:latest jq --version<br>            <br>            - echo &quot;Debug mode&quot;<br>            - docker run --rm -e PIPE_TEST_MODE=true -e DEBUG=true test-pipe:latest /bin/bash -c &quot;echo &#39;Debug mode test passed&#39;&quot;<br>            <br>            - echo &quot;Variable validation (should fail)&quot;<br>            - docker run --rm -e PIPE_TEST_MODE=true test-pipe:latest /bin/bash -c &quot;exit 0&quot; || echo &quot;Expected failure for missing variables&quot;<br>            <br>            - echo &quot;Script syntax validation&quot;<br>            - docker run --rm -e PIPE_TEST_MODE=true test-pipe:latest /bin/bash -n /opt/pipe/pipe.sh<br>            <br>            - echo &quot;All tests passed!&quot; </pre><h3>The GitOps Magic in Action</h3><p>Here’s how your GitOps pipeline becomes beautifully simple with the pipe:</p><pre># In your application repository (bitbucket-pipelines.yml)<br>pipelines:<br>  branches:<br>    main:<br>      - step:<br>          name: Build and Update GitOps Repo<br>          script:<br>            - pipe: docker://your-registry/ecr-build-helm-update-pipe:latest<br>              variables:<br>                ECR_REPO: &quot;my-awesome-service&quot;<br>                DOCKERFILE_PATH: &quot;Dockerfile&quot;<br>                # GitOps repository configuration<br>                HELM_PATH: &quot;apps/my-service/values-production.yaml&quot;<br>                HELM_REPO: &quot;bitbucket.org/your-team/k8s-gitops&quot;<br>                HELM_BRANCH: &quot;main&quot;<br>                HELM_UPDATE_MODE: &quot;tag-only&quot;<br>                AWS_ACCESS_KEY_ID: $AWS_ACCESS_KEY_ID<br>                AWS_SECRET_ACCESS_KEY: $AWS_SECRET_ACCESS_KEY<br>                ECR_REGISTRY: $ECR_REGISTRY<br>                TOKEN: $GITOPS_REPO_TOKEN</pre><h3>Key Features and Configuration Options</h3><p>Supported Variables</p><pre><br>┌──────────────────────┬──────────┬──────────────────────────────────────┬─────────────┐<br>│ Variable             │ Required │ Description                          │ Default     │<br>├──────────────────────┼──────────┼──────────────────────────────────────┼─────────────┤<br>│ ECR_REPO             │ Yes      │ ECR repository name                  │ -           │<br>│ DOCKERFILE_PATH      │ No       │ Path to Dockerfile                   │ Dockerfile  │<br>│ HELM_PATH            │ Yes      │ Path to Helm values file             │ -           │<br>│ HELM_REPO            │ Yes      │ GitOps repository URL                │ -           │<br>│ HELM_BRANCH          │ No       │ GitOps repository branch             │ main        │<br>│ HELM_UPDATE_MODE     │ No       │ Update strategy                      │ auto        │<br>│ AWS_ACCESS_KEY_ID    │ Yes      │ AWS access key                       │ -           │<br>│ AWS_SECRET_ACCESS_KEY│ Yes      │ AWS secret key                       │ -           │<br>│ ECR_REGISTRY         │ Yes      │ ECR registry URL                     │ -           │<br>│ TOKEN                │ Yes      │ Git repository token                 │ -           │<br>│ DEBUG                │ No       │ Enable debug mode                    │ false       │<br>│ MAX_BUILD_RETRIES    │ No       │ Build retry attempts                 │ 3           │<br>│ ASSUME_ROLE_ENABLED  │ No       │ Enable AWS assume role               │ false       │<br>└──────────────────────┴──────────┴──────────────────────────────────────┴─────────────┘</pre><h4>Helm Update Modes</h4><ol><li><strong>tag-only</strong>: Updates only the image tag, preserving the repository field</li><li><strong>repository-and-tag</strong>: Updates both repository and tag fields</li><li><strong>auto</strong>: Automatically detects the format and updates accordingly</li></ol><h4>Cross-Account AWS Support</h4><p>The pipe supports AWS cross-account deployments using STS assume role:</p><pre>variables:<br>  ASSUME_ROLE_ENABLED: &quot;true&quot;<br>  ASSUME_ROLE_ARN: &quot;arn:aws:iam::TARGET-ACCOUNT:role/DeploymentRole&quot;<br>  ASSUME_ROLE_SESSION_NAME: &quot;bitbucket-deployment&quot;<br>  ASSUME_ROLE_EXTERNAL_ID: &quot;your-external-id&quot;</pre><h3>Troubleshooting Common Issues</h3><h4>Build Failures</h4><ol><li><strong>Docker Build Timeout</strong>: Increase the step size in your pipeline</li><li><strong>Permission Denied</strong>: Ensure proper IAM permissions for ECR</li><li><strong>Network Issues</strong>: Implement retry logic with exponential backoff</li></ol><h4>GitOps Repository Issues</h4><ol><li><strong>Authentication Failures</strong>: Verify token permissions</li><li><strong>Branch Not Found</strong>: Check the branch name and repository access</li><li><strong>Merge Conflicts</strong>: Implement conflict resolution strategies</li></ol><h4>AWS ECR Issues</h4><ol><li><strong>Registry Not Found</strong>: Verify ECR repository exists</li><li><strong>Authentication Expired</strong>: Implement token refresh logic</li><li><strong>Cross-Account Access</strong>: Configure the assume role properly</li></ol><p>Whether you’re managing a single application or orchestrating deployments across multiple environments, this pipe provides a solid foundation for your GitOps CI/CD pipeline. The combination of Bitbucket Pipes’ simplicity with the power of GitOps creates a deployment workflow that’s both robust and maintainable.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2952ab2197d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Copy Data from One PVC to Another in OpenShift]]></title>
            <link>https://medium.com/@jimoh_abdol/how-to-copy-data-from-one-pvc-to-another-in-openshift-796b4dfe428c?source=rss-7f144da93169------2</link>
            <guid isPermaLink="false">https://medium.com/p/796b4dfe428c</guid>
            <dc:creator><![CDATA[Jimoh Abdulrahman]]></dc:creator>
            <pubDate>Sat, 13 Jul 2024 09:56:46 GMT</pubDate>
            <atom:updated>2024-07-13T10:02:56.477Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*C8SnskgGv5lpq-IE8n3VtA.png" /></figure><p>As applications grow, they generate more data. This can fill your Persistent Volume Claim (PVC). In OpenShift, you can transfer data to a larger PVC with minimal downtime and data loss.</p><p><strong>Prerequisites</strong></p><p>Before you begin, ensure you have the following:<br>- A running OpenShift cluster<br>- <a href="https://docs.openshift.com/container-platform/4.11/cli_reference/openshift_cli/getting-started-cli.html"><em>oc</em> </a>CLI tool installed and configured<br>- Access to the project/namespace where your PVC resides<br>- Sufficient permissions to create and manage PVCs and pods</p><p><strong>Step-by-Step Guide</strong></p><p><strong>1. Create a new Persistent Volume Claim</strong> (<strong>PVC)</strong></p><p>First, create a new PVC with the desired storage size.</p><pre>apiVersion: v1<br>kind: PersistentVolumeClaim<br>metadata:<br> name: new-pvc<br>spec:<br> accessModes:<br> - ReadWriteOnce<br> resources:<br> requests:<br> storage: 2Gi</pre><p>Apply this configuration using <em>oc</em></p><pre>oc apply -f new-pvc.yaml</pre><p><strong>2. Create a service account</strong></p><p>Create a service account and grant the service account <em>anyuid</em> policy</p><pre>oc create sa $SERVICE_ACCOUNT<br>oc adm policy add-scc-to-user anyuid system:serviceaccount:$NAMESPACE:$SERVICE_ACCOUNT</pre><p><strong>3. Create a job for the data migration</strong></p><p>Next, we’ll create a Kubernetes Job to migrate data. This job will use the service account you created earlier.</p><pre>apiVersion: batch/v1<br>kind: Job<br>metadata:<br>  name: migrate-pvc<br>spec:<br>  template:<br>    spec:<br>      # Added a service account for OpenShift<br>      serviceAccountName: serviceAccountName<br>      containers:<br>      - name: migrate-pvc<br>        image: debian<br>        command: [ &quot;/bin/bash&quot;, &quot;-c&quot; ]<br>        args:<br>          -<br>            apt-get update &amp;&amp; apt-get install -y rsync &amp;&amp;<br>            ls -lah /src_vol /dst_vol &amp;&amp;<br>            df -h &amp;&amp;<br>            rsync -avPS --delete /src_vol/ /dst_vol/ &amp;&amp;<br>            ls -lah /dst_vol/ &amp;&amp;<br>            du -shxc /src_vol/ /dst_vol/<br>        volumeMounts:<br>        - mountPath: /src_vol<br>          name: src<br>          readOnly: true<br>        - mountPath: /dst_vol<br>          name: dst<br>      restartPolicy: Never<br>      volumes:<br>      - name: src<br>        persistentVolumeClaim:<br>          claimName: source-pvc<br>      - name: dst<br>        persistentVolumeClaim:<br>          claimName: destination-pvc<br>  backoffLimit: 1</pre><p>Apply this configuration:</p><pre>oc apply -f migrate-pvc.yaml</pre><p><strong>4. Verify the Job Execution</strong><br>Check the status of the job to ensure it runs successfully</p><pre>oc get jobs -o wide</pre><p><strong>5. Update Your Application to Use the New PVC</strong></p><p>Once you’ve verified the data, update your application to use the new PVC. This involves modifying your deployment or stateful set configuration to mount the new PVC.</p><p><strong>6. Clean Up</strong></p><p>Finally, once you’ve confirmed that your application is running correctly with the new PVC, you can delete the job and the old PVC if they are no longer needed:</p><pre>oc delete job migrate-pvc<br>oc delete pvc source-pvc</pre><p><strong>Conclusion</strong></p><p>Following these steps, moving data from one PVC to another in OpenShift is simple. This will ensure a smooth transition with minimal downtime. Always verify the data after transfer and update your application configurations. <a href="https://justyn.io/til/migrate-kubernetes-pvc-to-another-pvc/">https://justyn.io/til/migrate-kubernetes-pvc-to-another-pvc/</a></p><p>Happy migrating!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=796b4dfe428c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying to Amazon ECS with GitHub Actions]]></title>
            <link>https://medium.com/@jimoh_abdol/deploying-to-amazon-ecs-with-github-actions-e5cb96bb707e?source=rss-7f144da93169------2</link>
            <guid isPermaLink="false">https://medium.com/p/e5cb96bb707e</guid>
            <dc:creator><![CDATA[Jimoh Abdulrahman]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 12:35:11 GMT</pubDate>
            <atom:updated>2024-01-17T12:35:11.522Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/870/1*-kBn6Qp35QSc6F_oFcBxFg.png" /></figure><p>GitHub Actions provides a convenient way to automate deployments to Amazon Elastic Container Service (Amazon ECS) directly from your GitHub repository. In this post, I’ll walk through a GitHub Actions workflow for building a Docker container image, pushing it to Amazon Elastic Container Registry (Amazon ECR), and deploying it as a new task definition revision to an Amazon ECS service.</p><p><strong>Prerequisites</strong></p><p>Before getting started with the workflow, we need:</p><p>- An Amazon ECS cluster and service already configured<br>- An Amazon ECR repository for storing container images <br>- AWS credentials stored as GitHub repo secrets for the workflow to access AWS</p><p>The AWS credentials require IAM permissions to push to Amazon ECR, describe/update Amazon ECS task definitions, and update the Amazon ECS service.</p><p><strong>The GitHub Actions Workflow</strong></p><p>Here is an overview of what our `.github/workflows/deploy.yml` workflow will do:</p><p>1. Checkout code from the GitHub repo<br>2. Configure AWS credentials from repo secrets<br>3. Authenticate with Amazon ECR <br>4. Build, tag, and push the Docker image to Amazon ECR <br>5. Download the current task definition from Amazon ECS<br>6. Update the new container image in the definition <br>7. Deploy the updated task definition to Amazon ECS</p><p><strong>Step-by-step Walkthrough</strong></p><p>Let’s take a closer look at each step:</p><p><strong>Checkout Code</strong></p><p>This uses the standard `actions/checkout` action to checkout our code.</p><pre>- name: Checkout<br> uses: actions/checkout@v1</pre><p><strong>Configure AWS Credentials</strong></p><p>Next, we set up access to AWS using credentials stored as secrets in the repository settings:</p><pre>- name: Configure AWS credentials<br> uses: aws-actions/configure-aws-credentials@v1<br> with:<br> aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}<br> aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br> aws-region: us-west-2</pre><p><strong>Authenticate with Amazon ECR</strong></p><p>We need to authenticate Docker with Amazon ECR so we can push images. The `amazon-ecr-login` action handles this for us:</p><pre>- name: Login to Amazon ECR<br> id: login-ecr<br> uses: aws-actions/amazon-ecr-login@v1</pre><p>This will return a registry URL for the next step.</p><p><strong>Build, Tag, and Push Image</strong></p><p>Here we build the Docker image, tag it properly for our ECR repo, and push it:</p><pre>- name: Build, tag, and push image to Amazon ECR<br> env:<br> ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }} <br> ECR_REPOSITORY: ${{ secrets.ECR_REPOSITORY }}<br> IMAGE_TAG: latest <br> run: |<br> docker build -t $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG .<br> docker push $ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG</pre><p>The `$ECR_REGISTRY` and repo name `$ECR_REPOSITORY` are set via environment variables populated by previous steps.</p><p><strong>Download Current Task Definition</strong></p><p>We need the current task definition JSON from Amazon ECS so we can update the container image in it:</p><pre>- name: Download task definition <br> run: |<br> aws ecs describe-task-definition - task-definition etap-development - query taskDefinition &gt; task-definition.json</pre><p><strong>Update Container Image in Definition</strong></p><p>Next we use the `amazon-ecs-render-task-definition` action to update the container image in the task definition and render the new JSON.</p><p>We reference the container we want to update by name, and provide the new image ID:</p><pre>- name: Fill in new image ID in task definition<br> id: task-def<br> uses: aws-actions/amazon-ecs-render-task-definition@v1<br> with:<br> task-definition: task-definition.json <br> container-name: admin-backend <br> image: ${{ steps.build-image.outputs.image }}</pre><p>Deploy Updated Task Definition</p><p>Finally, we deploy the updated task definition rendered in the previous step:</p><pre>- name: Deploy Amazon ECS task definition<br> uses: aws-actions/amazon-ecs-deploy-task-definition@v1 <br> with:<br> task-definition: ${{ steps.task-def.outputs.task-definition }}<br> service: admin-backend<br> cluster: dev-env</pre><p>We reference the updated definition, and point it to our desired ECS service and cluster.</p><p>And that’s it! The service will now deploy the new image and our code changes will be live.</p><p><strong>Conclusion</strong></p><p>Configuring automated deployments to Amazon ECS is straightforward with GitHub Actions. This provides a CI/CD pipeline to easily build, package, and deploy container updates.</p><p>Happy Deployment!!!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e5cb96bb707e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploying AWS Elastic Beanstalk with GitHub Actions]]></title>
            <link>https://medium.com/@jimoh_abdol/deploying-aws-elastic-beanstalk-with-github-actions-6fc405d57f30?source=rss-7f144da93169------2</link>
            <guid isPermaLink="false">https://medium.com/p/6fc405d57f30</guid>
            <dc:creator><![CDATA[Jimoh Abdulrahman]]></dc:creator>
            <pubDate>Wed, 17 Jan 2024 07:59:32 GMT</pubDate>
            <atom:updated>2024-01-17T08:06:44.627Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/953/1*eEeFj9-IQO31ccRA5O3BLw.png" /></figure><h3>Introduction</h3><p>AWS Elastic Beanstalk provides a scalable and easy-to-use platform for deploying and managing applications in the AWS Cloud. Integrating GitHub Actions into your workflow allows you to automate the build and deployment process, ensuring a seamless and efficient deployment pipeline. In this article, we’ll explore how to deploy an application to AWS Elastic Beanstalk using GitHub Actions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*Hb2gHpUjp8CtvOK7.png" /></figure><p><strong>GitHub Actions Workflow</strong></p><p>The provided GitHub Actions workflow (build.yml) is split into two jobs: `build` and `deploy`. Let’s break down each step:</p><ol><li><strong>Build Job:</strong><br>- Runs on: Ubuntu Latest<br>- Environment: your-credentials-github-environment</li></ol><pre>jobs:<br> build:<br> runs-on: ubuntu-latest<br> environment: your-credentials-github-environment</pre><p>Steps:</p><ul><li>Configure AWS credentials:</li></ul><pre>- name: Configure AWS credentials<br> uses: aws-actions/configure-aws-credentials@v1<br> with:<br> aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}<br> aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br> aws-region: ${{ env.AWS_REGION }}</pre><p>This step configures AWS credentials using GitHub Secrets, allowing secure access to AWS services.</p><ul><li>Login to Amazon ECR:</li></ul><pre>- name: Login to Amazon ECR<br> id: login-ecr<br> uses: aws-actions/amazon-ecr-login@v1</pre><p>Authenticates with Amazon Elastic Container Registry (ECR) to enable pushing Docker images.</p><ul><li>Check out the code:</li></ul><pre>- name: Check out code<br> uses: actions/checkout@v3</pre><p>Fetches the source code from the GitHub repository.</p><ul><li>Build the Docker image:</li></ul><pre>- name: Build the Docker image<br> run: docker build . - tag ${{ steps.login-ecr.outputs.registry }}/admin:${{ env.PIPELINE_ID }} - tag ${{ steps.login-ecr.outputs.registry }}/admin:latest</pre><p>Builds a Docker image and tags it with the GitHub Actions pipeline ID and ‘latest’.</p><ul><li>Push the Docker image to Amazon ECR:</li></ul><pre>- name: Push the Docker image to Amazon ECR<br> run: docker push - all-tags ${{ steps.login-ecr.outputs.registry }}/admin</pre><p>Pushes the Docker image to Amazon ECR, making it available for Elastic Beanstalk deployment.</p><p><strong>2. Deploy Job:</strong></p><p>- Needs: build<br>- Runs on: Ubuntu Latest<br>- Environment: your-github-environment</p><pre>jobs:<br> deploy:<br> needs: build<br> runs-on: ubuntu-latest<br> environment: your-github-environment</pre><p>- Steps:</p><ul><li>Check out the code:</li></ul><pre>- name: Check out code<br> uses: actions/checkout@v3</pre><p>Fetches the source code in the deployment job.</p><ul><li>Generate deployment package:</li></ul><pre>- name: Generate deployment package<br> run: zip deploy.zip Dockerrun.aws.json</pre><p>Creates a deployment package containing the Dockerrun.aws.json file.</p><ul><li>Deploy to AWS Elastic Beanstalk:</li></ul><pre>- name: Deploy to AWS Elastic BeanTalk<br> uses: einaregilsson/beanstalk-deploy@v20<br> with:<br> aws_access_key: ${{ secrets.AWS_ACCESS_KEY_ID }}<br> aws_secret_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}<br> application_name: admin-client<br> environment_name: Adminclient-env<br> version_label: ${{ env.PIPELINE_ID }}<br> use_existing_version_if_available: true<br> region: ${{ env.AWS_REGION }}<br> deployment_package: deploy.zip</pre><p>Utilizes the `beanstalk-deploy` action to deploy the application to AWS Elastic Beanstalk using the specified configurations.</p><p><strong>Conclusion</strong></p><p>By incorporating GitHub Actions into your workflow, you can automate the build and deployment of your AWS Elastic Beanstalk applications. This provides a reliable and efficient way to deliver your code changes seamlessly from development to production. Feel free to customize the workflow according to your specific project requirements, and leverage the power of continuous integration and continuous deployment in your development pipeline.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6fc405d57f30" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Embracing the Future: DevOps in 2024]]></title>
            <link>https://medium.com/@jimoh_abdol/embracing-the-future-devops-in-2024-14e9c835ae11?source=rss-7f144da93169------2</link>
            <guid isPermaLink="false">https://medium.com/p/14e9c835ae11</guid>
            <dc:creator><![CDATA[Jimoh Abdulrahman]]></dc:creator>
            <pubDate>Mon, 01 Jan 2024 08:45:16 GMT</pubDate>
            <atom:updated>2024-01-01T08:45:16.252Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*_D9qzDRHDjQnWt04uwsCkw.jpeg" /></figure><p>As we step into 2024, the DevOps landscape continues to evolve, presenting exciting opportunities and challenges for professionals in the field. Over the past few years, DevOps practices have become integral to modern software development, emphasizing collaboration, automation, and continuous improvement. In this article, we’ll explore key trends and strategies that will shape the DevOps world in 2024, helping teams stay ahead in this dynamic and fast-paced environment.</p><p><strong>1. Cloud-Native Dominance</strong></p><p>Cloud-native technologies have been on the rise, and in 2024, we anticipate a deeper integration of cloud services into DevOps workflows. With the maturation of Kubernetes and other container orchestration tools, organizations are streamlining deployment processes, achieving scalability, and enhancing resilience. This section will delve into best practices for managing cloud-native environments and optimizing workflows for efficiency.</p><p><strong>2. AI and Machine Learning in DevOps</strong></p><p>As we move further into the future, the role of artificial intelligence (AI) and machine learning (ML) in DevOps is becoming increasingly prominent. Automation has always been a cornerstone of DevOps, but with the incorporation of AI, teams can leverage predictive analytics, anomaly detection, and intelligent decision-making. Explore how AI-driven insights can enhance monitoring, reduce downtime, and contribute to a more proactive approach to system maintenance.</p><p><strong>3. Security-First DevOps</strong></p><p>Security is no longer an afterthought in the DevOps lifecycle; it’s an integral part of every stage. In 2024, we’ll witness a heightened focus on integrating security practices seamlessly into DevOps processes. From DevSecOps strategies to the adoption of security-as-code principles, this section will guide you through the evolving landscape of securing applications and infrastructure.</p><p><strong>4. GitOps and Infrastructure as Code (IaC)</strong></p><p>GitOps, the practice of using Git as a single source of truth for infrastructure and applications, continues to gain momentum. Combined with Infrastructure as Code (IaC), teams can achieve version-controlled, automated infrastructure deployments. Learn how GitOps and IaC contribute to more reliable, auditable, and collaborative development and operations processes.</p><p><strong>Navigating the DevOps Landscape in 2024</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*duas4jO7DqJXiyLsRC5JRw.png" /></figure><p>As we navigate the DevOps landscape in 2024, it’s crucial to embrace change, foster collaboration, and stay informed about the latest technologies. The trends discussed in this article represent just a glimpse into the future of DevOps. By continuously learning, adapting, and embracing innovation, DevOps professionals can play a pivotal role in shaping the way organizations deliver software in the years to come.</p><p>What are your predictions and insights for DevOps in 2024? Share your thoughts and experiences in the comments below!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14e9c835ae11" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Streamlining Development Workflows with Docker: Building Images Directly from Git Repositories]]></title>
            <link>https://medium.com/@jimoh_abdol/streamlining-development-workflows-with-docker-building-images-directly-from-git-repositories-bfc18ca661fb?source=rss-7f144da93169------2</link>
            <guid isPermaLink="false">https://medium.com/p/bfc18ca661fb</guid>
            <dc:creator><![CDATA[Jimoh Abdulrahman]]></dc:creator>
            <pubDate>Sun, 17 Dec 2023 14:30:23 GMT</pubDate>
            <atom:updated>2023-12-17T14:30:23.801Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*c6srCJLFkTXMYhsW" /></figure><p>In the fast-paced world of DevOps, where efficiency is key, every small improvement to our development workflow can make a significant impact. Docker, the leading containerization platform, offers a powerful but often overlooked feature that can enhance your workflow: the ability to build Docker images directly from Git repositories. This not only saves time but also simplifies your development process.</p><p><strong>The Traditional Approach</strong> 🔄</p><p>Traditionally, developers would follow these steps to build a Docker image for their application:</p><p>1. Clone the Git Repository:<br> — Manually clone the Git repository to their local machine.<br> — Navigate to the project directory.</p><p>2. Create a Dockerfile:<br> — Write a Dockerfile with the necessary instructions for building the image.<br> — Specify the base image, set the working directory, copy files, and define the commands to run.</p><p>3. Build the Docker Image:<br> — Run the `docker build` command, pointing to the local directory with the Dockerfile.<br> — Wait for the image to be built.</p><p>4. Run a Docker Container:<br> — Finally, run a container from the built image.</p><p><strong>The Game-Changing Docker Feature</strong> 🚀</p><p>Now, here’s the game-changing feature: Docker allows you to skip the first step altogether! You can directly build Docker images from your Git repositories, eliminating the need to manually clone them first. This feature not only saves time but also reduces the chances of errors related to manual processes.</p><p>How to Use This Feature 🛠️</p><p>Let’s walk through the steps to build a Docker image directly from a Git repository:</p><ol><li>Create a Dockerfile:<br> — Write a Dockerfile in your project directory as usual.</li></ol><pre>FROM busybox<br>MAINTAINER Abdulrahman Jimoh<br><br>CMD [&quot;echo&quot;, &quot;Hello World! From Abdulrahman Jimoh!&quot;]</pre><p>2. Commit Dockerfile to Git:<br> — Commit the Dockerfile to your Git repository.</p><pre>git add Dockerfile<br> git commit -m &quot;Add Dockerfile for containerization&quot;<br> git push origin main</pre><p>3. Build the Docker Image:<br> — Run the following command, providing the Git repository URL.</p><pre>docker build https://github.com/docker/rootfs.git#container:docker</pre><p>In this example, <strong>#container</strong> specifies the branch and <strong>:docker</strong> specifies the working directory.</p><p>4. Verify:<br> — Verify that the Docker image is created successfully.</p><pre>docker images</pre><p><strong>Conclusion</strong></p><p>Building Docker images directly from Git repositories is a small but impactful feature that aligns with the principles of simplicity and efficiency. By integrating this approach into your workflow, you can save time, reduce manual steps, and ensure a more seamless development experience. Embrace the power of Docker and streamline your containerization process today! 🐳💻</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=bfc18ca661fb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Bitbucket Pipeline for Terraform Automation]]></title>
            <link>https://medium.com/@jimoh_abdol/bitbucket-pipeline-for-terraform-automation-366ca3f14014?source=rss-7f144da93169------2</link>
            <guid isPermaLink="false">https://medium.com/p/366ca3f14014</guid>
            <dc:creator><![CDATA[Jimoh Abdulrahman]]></dc:creator>
            <pubDate>Sun, 26 Nov 2023 07:16:59 GMT</pubDate>
            <atom:updated>2023-11-26T08:09:25.259Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8PNgu6BtqbO7nMSqhmH8-g.png" /></figure><p><strong>Overview</strong></p><p>The Bitbucket Pipeline described here automates Terraform workflows for infrastructure provisioning and management. It uses Bitbucket’s pipeline functionality to execute Terraform commands based on specific events and manual triggers.</p><p><strong>Pipeline Structure</strong></p><p>The pipeline configuration (`bitbucket-pipelines.yml`) is structured as follows:</p><pre>image: hashicorp/terraform:latest<br><br>pipelines:<br>  branches:<br>    # Run Terraform init and plan for any push event on any branch<br>    &#39;**&#39;:<br>      - step:<br>          name: Terraform Init and Plan<br>          script:<br>            - terraform init<br>            - terraform plan<br>    &#39;master&#39;:<br>      - step:<br>          name: Terraform Init and Plan<br>          script:<br>            - terraform init<br>            - terraform apply -auto-approve<br><br>  # Manual trigger for Terraform destroy<br>  manual:<br>    - step:<br>        name: Manual Destroy<br>        script:<br>          - terraform destroy<br>        trigger: manual</pre><p><strong>Branch-based Execution</strong></p><p>- For Any Branch Push Event:<br> — Executes `terraform init` and `terraform plan` automatically for any push event on any branch.</p><p><strong>Master Branch Merge Event</strong></p><p>- For Merge to Master:<br> — Executes `terraform init` and subsequently applies changes with `terraform apply — auto-approve` only on merge events to the master branch.</p><p><strong>Manual Trigger for Destroy</strong></p><p>- Manual Trigger:<br> — Allows manual initiation of `terraform destroy` to tear down infrastructure manually when needed.</p><p>Usage Instructions</p><p>Automatic Execution on Push Events</p><p>- For Development Branches:<br> — Whenever a push event occurs on any branch, Bitbucket Pipeline automatically runs `terraform init` and `terraform plan`.</p><p>Applying Changes to Master Branch</p><p>- Merge to Master:<br> — Upon merging changes to the master branch, the pipeline executes `terraform init`, `terraform plan`, and applies changes using `terraform apply — auto-approve`.</p><p>Manual Destruction of Infrastructure</p><p>- Manual Trigger:<br> — To manually destroy infrastructure provisioned by Terraform, follow these steps:<br> 1. Go to your Bitbucket repository.<br> 2. Navigate to the “Pipelines” section.<br> 3. Find the appropriate pipeline run related to the infrastructure you want to destroy.<br> 4. Click on “Run pipeline.”<br> 5. Select the “Manual Destroy” step.<br> 6. Click the “Run” button to trigger the `terraform destroy` command manually.</p><p>Notes and Considerations</p><p>- Sensitive Information:<br> — Ensure that sensitive information such as API keys or credentials is handled securely in your actual implementation.<br>- Safety Measures:<br> — Implement confirmation prompts or additional safety measures to prevent accidental destruction in production environments.<br>- Customization:<br> — Adjust the pipeline configuration (`bitbucket-pipelines.yml`) according to your specific Terraform setup and project requirements.</p><p>— -.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=366ca3f14014" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>