<?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 NC on Medium]]></title>
        <description><![CDATA[Stories by NC on Medium]]></description>
        <link>https://medium.com/@ppnc?source=rss-1378eadff68------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*uOZZjfl08SjqivztvdaJeg.png</url>
            <title>Stories by NC on Medium</title>
            <link>https://medium.com/@ppnc?source=rss-1378eadff68------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 17 Nov 2026 01:44:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ppnc/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[ลด cost บน Kubernetes Cluster ด้วย kube-downscaler]]></title>
            <link>https://medium.com/convolab/%E0%B8%A5%E0%B8%94-cost-%E0%B8%9A%E0%B8%99-kubernetes-cluster-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-kube-downscaler-7ca9c5d39fb9?source=rss-1378eadff68------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ca9c5d39fb9</guid>
            <category><![CDATA[autoscaling]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[NC]]></dc:creator>
            <pubDate>Fri, 23 Aug 2019 11:20:42 GMT</pubDate>
            <atom:updated>2019-08-23T11:20:42.507Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/463/1*GlAGCIybYVOj4eQVWFxKmA.png" /></figure><p>วันนี้มาแนะนำ tool ทำ schedule เพื่อเปิด/ปิดการใช้งาน workload ที่ไม่จำเป็นต้องเปิดใช้งานตลอดบน cluster เช่น เปิดใช้เฉพาะ work hours เท่านั้น โดยใช้คู่กับ cluster autoscale ของ kubernetes จะช่วยลดค่าใช้จ่ายได้เยอะมากนั่นเอง</p><h3><strong>Prerequisite</strong></h3><ul><li>Kubernetes Cluster ที่เปิดใช้ cluster autoscaler (ในที่นี้ใช้ GKE)</li><li>kubectl : รายละเอียดการติดตั้ง <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/">https://kubernetes.io/docs/tasks/tools/install-kubectl/</a></li></ul><h3>Setup</h3><p>โหลดและติดตั้ง deployment จาก <a href="https://github.com/hjacobs/kube-downscaler">kube-downscaler</a> repository</p><blockquote>git clone <a href="https://github.com/hjacobs/kube-downscaler.git">https://github.com/hjacobs/kube-downscaler.git</a><br>kubectl apply -f kube-downscaler/deploy/</blockquote><p>Edit deployment เอา — dry-run ออกเพื่อใช้งาน downscale</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/672/1*iO5dmgkIr8N7FEd2HDhAPw.png" /><figcaption>kubectl edit deploy kube-downscaler</figcaption></figure><p>การตั้ง default schedule</p><p>ตั้งค่า DEFAULT_UPTIME หรือ DEFAULT_DOWNTIME ใน configMap ของ kube-downscaler โดยจะ apply กับทุก deployment ยกเว้นใน namespace kube-system</p><p>การตั้ง time format</p><blockquote>&lt;WEEKDAY-FROM&gt;-&lt;WEEKDAY-TO-INCLUSIVE&gt; &lt;HH&gt;:&lt;MM&gt;-&lt;HH&gt;:&lt;MM&gt; &lt;TIMEZONE&gt;</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/570/1*iVHyuKsqZrp2huCLoW7frA.png" /><figcaption>kubectl edit configMap kube-downscaler</figcaption></figure><p>เรายังสามารถใช้ Annotation ตั้งค่า schedule ให้เฉพาะ deployment ที่เราต้องการได้ด้วย เช่น</p><blockquote>kubectl annotate deploy &lt;DEPLOYMENT&gt; “downscaler/uptime=&lt;TIME-FORMAT&gt;”</blockquote><p>หรือจะยกเว้นการ downscale ให้กับ deployment บางตัว เช่น</p><blockquote>kubectl annotate deploy &lt;DEPLOYMENT&gt; “downscaler/exclude: true”</blockquote><p>สามารถศึกษา option การใช้งานเพิ่มเติมได้ที่<br><a href="https://github.com/hjacobs/kube-downscaler">https://github.com/hjacobs/kube-downscaler</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ca9c5d39fb9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/convolab/%E0%B8%A5%E0%B8%94-cost-%E0%B8%9A%E0%B8%99-kubernetes-cluster-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-kube-downscaler-7ca9c5d39fb9">ลด cost บน Kubernetes Cluster ด้วย kube-downscaler</a> was originally published in <a href="https://medium.com/convolab">ConvoLab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Monitor cost บน GKE Cluster ง่ายๆ ด้วย Kubecost]]></title>
            <link>https://medium.com/convolab/monitor-cost-%E0%B8%9A%E0%B8%99-gke-cluster-%E0%B8%87%E0%B9%88%E0%B8%B2%E0%B8%A2%E0%B9%86-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-kubecost-fdce0ef8e47?source=rss-1378eadff68------2</link>
            <guid isPermaLink="false">https://medium.com/p/fdce0ef8e47</guid>
            <category><![CDATA[google-kubernetes-engine]]></category>
            <category><![CDATA[monitoring]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[helm]]></category>
            <dc:creator><![CDATA[NC]]></dc:creator>
            <pubDate>Fri, 14 Jun 2019 05:01:00 GMT</pubDate>
            <atom:updated>2019-06-14T05:01:00.838Z</atom:updated>
            <content:encoded><![CDATA[<h3>Monitor Cost บน GKE Cluster ง่าย ๆ ด้วย Kubecost</h3><p>แนะนำ Tool น่าสนใจตัวนึงที่สามารถแจง Cost ของส่วนต่าง ๆ ของ Workload บน Kubernetes ซึ่งสามารถแนะนำและ predict issue ต่าง ๆ บน Cluster ได้อีกด้วย ซึ่งมีประโยชน์มากในการวิเคราะห์การใช้งานและลดค่าใช้จ่ายของ Cluster</p><p><strong>สิ่งที่ต้องเตรียม:<br></strong>- <strong>GKE Cluster </strong>ที่ใช้งานอยู่<br>- <strong>kubectl </strong>: รายละเอียดการติดตั้ง <a href="https://kubernetes.io/docs/tasks/tools/install-kubectl/">https://kubernetes.io/docs/tasks/tools/install-kubectl/</a><br>- <strong>helm client</strong> : รายละเอียดการติดตั้ง <a href="https://helm.sh/docs/using_helm/">https://helm.sh/docs/using_helm/</a></p><p><strong>ขั้นตอนการติดตั้ง:</strong></p><ol><li><strong>สร้าง Service Account สำหรับ helm</strong></li></ol><p>ตั้งเป็น cluster-admin role เพื่อให้ tiller pod ต่อกับ kubernetes api ได้<br>kubectl apply -f ไฟล์ yaml ตามข้างล่าง</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/9ba00a5c4c30e0ab3102bae41f639d0d/href">https://medium.com/media/9ba00a5c4c30e0ab3102bae41f639d0d/href</a></iframe><p>จากนั้น RUN</p><blockquote>helm init — service-account helm</blockquote><p>แล้วเช็คความเรียบร้อยโดยดูว่ามี deployment และ service ของ tiller-deploy ใน kube-system namespace หรือไม่</p><p><strong>2. เปิด Billing API ของ Google Cloud</strong></p><p>ไปที่หน้า Console ของ Google Cloud &gt; เลือก navigation menu ที่มุมซ้ายบน &gt; APIs &amp; Services &gt; Library &gt; search แล้วเลือกไปที่ Cloud Billing API แล้วทำการ enable</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/932/1*k2ZPBcifcjBXF69Ft1riqw.png" /></figure><p><strong>3. ติดตั้ง Kubecost ผ่าน helm</strong></p><p>เพิ่ม helm repo</p><blockquote>helm repo add kubecost <a href="https://kubecost.github.io/cost-analyzer/">https://kubecost.github.io/cost-analyzer/</a></blockquote><p>Install kubecost</p><p>โดย default จะลงทั้ง Prometheus กับ Grafana ด้วย กรณีจะลงแบบ custom สามารถเช็ค option ได้ที่ <a href="https://github.com/kubecost/cost-analyzer-helm-chart">https://github.com/kubecost/cost-analyzer-helm-chart</a> ตัวอย่าง เช่น ใช้กับ Prometheus ที่ลงไว้อยู่แล้ว</p><p>ตรง token ด้านล่างเช็คจากเว็บหลัก <a href="https://kubecost.com/">https://kubecost.com</a></p><blockquote>helm install kubecost/cost-analyzer — namespace kubecost — name kubecost — set kubecostToken=&lt;token&gt;</blockquote><p><strong>4. ใช้งาน Dashboard</strong></p><p>สามารถใช้วิธี port-forward มาที่ localhost ด้วยคำสั่ง</p><blockquote>kubectl port-forward — namespace kubecost deployment/kubecost-cost-analyzer 9090</blockquote><p>หรือจะ expose service ผ่าน ingress หรือ nodeport เพื่อให้ใช้งานจาก public ก็ได้</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OC3l-u4YZNGOZlk5GkFOeg.png" /><figcaption>ตัวอย่าง Dashboard</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdce0ef8e47" width="1" height="1" alt=""><hr><p><a href="https://medium.com/convolab/monitor-cost-%E0%B8%9A%E0%B8%99-gke-cluster-%E0%B8%87%E0%B9%88%E0%B8%B2%E0%B8%A2%E0%B9%86-%E0%B8%94%E0%B9%89%E0%B8%A7%E0%B8%A2-kubecost-fdce0ef8e47">Monitor cost บน GKE Cluster ง่ายๆ ด้วย Kubecost</a> was originally published in <a href="https://medium.com/convolab">ConvoLab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debug Node.js app บน Kubernetes ด้วย Chrome DevTools]]></title>
            <link>https://medium.com/convolab/https-bit-ly-2usf97n-1b1512882d9c?source=rss-1378eadff68------2</link>
            <guid isPermaLink="false">https://medium.com/p/1b1512882d9c</guid>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[chrome-dev-tools]]></category>
            <category><![CDATA[debug]]></category>
            <category><![CDATA[minikube]]></category>
            <category><![CDATA[nodejs]]></category>
            <dc:creator><![CDATA[NC]]></dc:creator>
            <pubDate>Sun, 24 Mar 2019 02:01:03 GMT</pubDate>
            <atom:updated>2019-03-24T02:01:03.592Z</atom:updated>
            <content:encoded><![CDATA[<h3>Debug Node.js App บน Kubernetes ด้วย Chrome DevTools</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/820/0*oWo3Kw13tRO32NUY.jpg" /><figcaption>Image source: <a href="https://www.bitdegree.org/learn/storage/media/images/de2e3e9e-6bf6-4082-b507-90ac4e58eeb6.o.jpg">https://www.bitdegree.org/</a></figcaption></figure><p>ปัญหาที่หลายคนอาจเคยเจอคือ การที่ไม่สามารถ reproduce bug บน local environment หรือแค่ขี้เกียจ set environment ตาม host ของ app ที่จะ debug</p><p>ในที่นี้จะแนะนำวิธีการ debug Nodejs app ใน pod ง่ายๆผ่าน Chrome</p><h4>สิ่งที่ต้องมี</h4><ul><li>Kubernetes Cluster ที่ใช้งานอยู่หรือ Minikube</li><li>kubectl เพื่อใช้ควบคุม cluster ตามที่ config ไว้</li></ul><h4>ขั้นตอนการติดตั้งและใช้งาน</h4><ol><li>เซ็ต app Nodejs ใน pod ให้สามารถ debug ได้ อาจจะแก้หรือสร้าง deployment ใหม่สำหรับ debug โดยเพิ่ม command เพื่อ start app ใน debug mode</li></ol><p>ตัวอย่างเพิ่ม command ใน deployment yaml เพื่อรัน app เป็น debug mode</p><blockquote>command: [ “node”, “ — inspect-brk”, “server.js” ]</blockquote><p>หรือ kubectl exec เข้าไปใน pod แล้ว start app เป็น debug mode เองด้วย — inspect-brk ก็ได้ โดย inspect port ค่า default จะเป็น 9229</p><p>2. Forward inspect port ของ Pod บน kubernetes มาที่ local</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*Ms-PrqJOiN1la8YsKr9Mcg.png" /><figcaption><strong>list รายชื่อ pod ที่จะ debug</strong></figcaption></figure><blockquote>kubectl port-forward &lt;pod_name&gt; 9229</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/411/1*y755k_XYn8x2qn3kihp6uw.png" /><figcaption><strong>forward port ของ pod มาที่ local</strong></figcaption></figure><p>3. เปิด Chrome แล้วเข้า link chrome://inspect เพื่อเปิด DevTools</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*qkYkdRIQwnk_WPP3PJ6QFA.png" /><figcaption><strong>ที่แท็บ devices ตรง Discovery network targets ให้ config target มาที่ localhost:9229</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/290/1*N68yOdfESW9a0WGHeH63Vw.png" /><figcaption><strong>เพิ่ม target มาที่ port 9229</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/507/1*j_uPYmUXqz2QZirTkN1y_A.png" /><figcaption><strong>ตรง Remote Target จะแสดง app ที่เราจะ debug ขึ้นมา</strong></figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/957/1*Ute6V0TNWWl1QEgSLjJyng.png" /><figcaption><strong>จากนั้นกดที่ inspect แล้วจะมี pop up ขึ้นมา ให้ไปที่ source &gt; Filesystem จะขึ้น code มา…</strong></figcaption></figure><p>ทีนี้เราก็สามารถ remote debug app บน Kubernetes ได้แล้วล่ะครับ</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1b1512882d9c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/convolab/https-bit-ly-2usf97n-1b1512882d9c">Debug Node.js app บน Kubernetes ด้วย Chrome DevTools</a> was originally published in <a href="https://medium.com/convolab">ConvoLab</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>