<?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 boyoon on Medium]]></title>
        <description><![CDATA[Stories by boyoon on Medium]]></description>
        <link>https://medium.com/@bo-yoon?source=rss-c58206db6ddf------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PGO0jIdNb2CfyPV-vOZm9A.png</url>
            <title>Stories by boyoon on Medium</title>
            <link>https://medium.com/@bo-yoon?source=rss-c58206db6ddf------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 08:12:33 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@bo-yoon/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[Structure of the Kubeconfig File]]></title>
            <link>https://medium.com/@bo-yoon/structure-of-the-kubeconfig-file-5b8e418c16f1?source=rss-c58206db6ddf------2</link>
            <guid isPermaLink="false">https://medium.com/p/5b8e418c16f1</guid>
            <category><![CDATA[kubernetes-cluster]]></category>
            <category><![CDATA[kubeconfig]]></category>
            <category><![CDATA[kubernetes-api]]></category>
            <category><![CDATA[kubernetes]]></category>
            <dc:creator><![CDATA[boyoon]]></dc:creator>
            <pubDate>Wed, 05 Feb 2025 08:42:46 GMT</pubDate>
            <atom:updated>2025-02-05T08:42:46.095Z</atom:updated>
            <content:encoded><![CDATA[<p>When accessing a Kubernetes cluster locally, you might notice that a ~/.kube/config file is automatically created in your home directory. If this file is missing, you won’t be able to connect to the cluster. But what exactly does this file contain, and what role does it play?</p><p>Let’s dive in and find out!</p><p>The Kubeconfig file contains the necessary information to <strong>connect to a Kubernetes cluster</strong>, including the cluster API address, authentication certificates, and context configurations.</p><p>Without this file, you would need to manually enter the API server address, authentication tokens, or set up environment variables every time you access the cluster. However, by using this file, Kubernetes can <strong>automatically retrieve these values</strong>, making cluster access much more convenient. Moreover, Kubeconfig is not limited to a single cluster. it allows you to <strong>manage multiple clusters within a single file</strong>.</p><p>Example kubeconfig file</p><pre>apiVersion: v1<br>kind: Config<br>clusters:<br>  - name: dev-cluster<br>    cluster:<br>      server: https://dev-cluster-api-server<br>      certificate-authority: /path/to/dev-ca.crt<br><br>  - name: prod-cluster<br>    cluster:<br>      server: https://prod-cluster-api-server<br>      certificate-authority: /path/to/prod-ca.crt<br><br>contexts:<br>  - name: dev-context<br>    context:<br>      cluster: dev-cluster<br>      user: dev-user<br>      namespace: dev-namespace<br><br>  - name: prod-context<br>    context:<br>      cluster: prod-cluster<br>      user: prod-user<br>      namespace: prod-namespace<br><br>users:<br>  - name: dev-user<br>    user:<br>      client-certificate: /path/to/dev-client.crt<br>      client-key: /path/to/dev-client.key<br><br>  - name: prod-user<br>    user:<br>      client-certificate: /path/to/prod-client.crt<br>      client-key: /path/to/prod-client.key<br><br>current-context: dev-context  </pre><p>The file is divided into four main sections: <strong>clusters, contexts, users, and current-context</strong>.</p><p>The current-context field indicates the <strong>currently active cluster</strong>. But what do clusters, contexts, and usersrepresent? Let’s explore each of them.</p><h3>Clusters Section</h3><p>The clusters section stores information about different Kubernetes clusters.</p><pre>clusters:<br>  - name: dev-cluster<br>    cluster:<br>      server: https://dev-cluster-api-server<br>      certificate-authority: /path/to/dev-ca.crt</pre><p>It includes the <strong>cluster name</strong>, <strong>Kubernetes API server address</strong>, and <strong>certificate authority (CA) file</strong> to establish secure communication between kubectl and the API server.</p><p><strong>[ AWS EKS Sample ]</strong></p><pre>clusters:<br>  - name: dev-cluster<br>    cluster:<br>      server: https://dev-cluster-api-server.eks.amazonaws.com<br>      certificate-authority-data: DDDDDDDDDD</pre><p>In AWS EKS, instead of certificate-authority, <strong>Base64-encoded certificate data</strong> (certificate-authority-data) is used to verify the API server’s authenticity.</p><blockquote><strong>“ What is a Certificate Authority (CA) Certificate?” <br></strong><em>The CA certificate ensures secure HTTPS (TLS) communication between the Kubernetes API server and clients like </em><em>kubectl. It helps verify whether the API server is trustworthy.</em></blockquote><blockquote><em>Without a valid CA certificate, you might encounter errors like:</em></blockquote><blockquote><em>Unable to connect to the server: x509: certificate signed by unknown authority</em></blockquote><blockquote><em>You can disable this verification using </em><em>insecure-skip-tls-verify: true, but this is not recommended due to security risks.</em></blockquote><h3>Users Section</h3><p>The users section stores <strong>authentication details</strong> for accessing the Kubernetes API server.</p><pre>users:<br>  - name: dev-user<br>    user:<br>      client-certificate: /path/to/dev-client.crt<br>      client-key: /path/to/dev-client.key</pre><p>The API server uses this information to <strong>authenticate the user before granting access</strong>.</p><p><strong>[ Authentication Methods ]</strong></p><ol><li><strong>client-certificate (Client Certificate)</strong> : Used to verify the user’s identity when making API requests.</li><li><strong>client-key (Client Key)</strong> : Encrypts communication with the API server, proving the client’s legitimacy.</li></ol><p>And then, Kubernetes also supports alternative authentication methods, such as <strong>IAM-based authentication, OIDC tokens, or exec plugins</strong>.</p><p><strong>[ AWS EKS Sample ] : </strong>using exec</p><pre>kind: Config<br>preferences: {}<br>users:<br>- name: test<br>  user:<br>    exec:<br>      apiVersion: client.authentication.k8s.io/v1beta1<br>      args:<br>      - --region<br>      - eks<br>      - get-token<br>      - --cluster-name<br>      - test<br>      - --output<br>      - json<br>      command: aws<br>      env: null<br>      interactiveMode: IfAvailable<br>      provideClusterInfo: false</pre><p><strong>In AWS EKS, </strong><strong>kubectl can authenticate automatically via IAM without requiring client certificates.</strong></p><h3>Contexts Section</h3><p>The contexts section groups <strong>cluster, user, and namespace information into a single profile</strong>, making it easier to switch between configurations</p><pre>contexts:<br>  - name: dev-context<br>    context:<br>      cluster: dev-cluster<br>      user: dev-user<br>      namespace: dev-namespace<br><br>  - name: prod-context<br>    context:<br>      cluster: prod-cluster<br>      user: prod-user<br>      namespace: prod-namespace<br><br>current-context: dev-context  </pre><p>With contexts, you can <strong>easily switch between clusters</strong>.</p><p>The command below changes the context to prod-context.</p><pre>kubectl config use-context prod-context </pre><p><strong>This allows </strong><strong>kubectl to automatically use the correct cluster and namespace settings.</strong></p><p>We’ve explored the role and structure of the Kubeconfig file. I hope this guide helps you better understand how the Kubeconfig file works!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5b8e418c16f1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Use the Declarative Approach?]]></title>
            <link>https://medium.com/@bo-yoon/why-use-the-declarative-approach-33c0d028bf4b?source=rss-c58206db6ddf------2</link>
            <guid isPermaLink="false">https://medium.com/p/33c0d028bf4b</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[devops-practice]]></category>
            <category><![CDATA[declarative-programming]]></category>
            <dc:creator><![CDATA[boyoon]]></dc:creator>
            <pubDate>Tue, 04 Feb 2025 04:26:49 GMT</pubDate>
            <atom:updated>2025-02-04T04:26:49.810Z</atom:updated>
            <content:encoded><![CDATA[<p>If you’ve worked with tools like Kubernetes or Terraform, you’ve probably come across the term <strong>“declarative.”</strong> But why is the declarative approach useful, and when should you use it?</p><h3><strong>What is the Declarative Approach?</strong></h3><p>The <strong>declarative approach</strong> means you define <strong>what the final state should look like</strong>, and the tool automatically figures out how to achieve that state. Since only the desired outcome is specified, it ensures <strong>consistency</strong> — running the same code always results in the same infrastructure, reducing differences across environments.</p><h3><strong>Declarative vs. Imperative Approaches</strong></h3><p>The declarative approach is often contrasted with the <strong>imperative approach</strong>.</p><p>In an <strong>imperative approach</strong>, you provide step-by-step instructions:</p><p><em>“Run A first, then apply B, and finally execute C.”</em></p><p>In a <strong>declarative approach</strong>, you simply define the desired state:</p><p><em>“Ensure A, B, and C exist in this state.”</em></p><p>The tool then determines what actions are needed to reach that state. Because of this, <strong>execution order doesn’t matter</strong>, and running the process multiple times always gives the same result.</p><p>For example, let’s say you want to scale a Kubernetes <strong>Deployment</strong> to 5 replicas.</p><p>If you use an <strong>imperative approach</strong>, you’d run this command:</p><pre>kubectl scale deployment app --replicas=5</pre><p>This changes the number of pods, but it doesn’t leave a record of <strong>who made the change and when</strong> unless manually documented.</p><p>Now, let’s compare it with a <strong>declarative approach</strong>:</p><pre>apiVersion: apps/v1<br>kind: Deployment<br>metadata:<br>  name: app<br>spec:<br>  replicas: 5<br>  selector:<br>    matchLabels:<br>      app: app<br>  template:<br>    metadata:<br>      labels:<br>        app: app<br>    spec:<br>      containers:<br>      - name: nginx<br>        image: nginx</pre><p>By managing configurations as code, it’s much easier to track changes. Any updates are committed to Git, so you always know <strong>who modified what and when</strong>.</p><h3>Why Is the Declarative Approach Useful?</h3><ol><li><strong>Automatic Change Management</strong></li></ol><p>Declarative systems store the <strong>current state</strong> somewhere (e.g., a state file or database). If the actual state drifts from what was declared, the system <strong>automatically detects and corrects</strong> the differences.</p><p>For example, <strong>Terraform’s tfstate file</strong> and <strong>Kubernetes’ etcd</strong> help ensure infrastructure stays in sync. This is also a key principle of <strong>GitOps</strong>, where Git acts as the single source of truth.</p><p><strong>2. Easier Maintenance</strong></p><p>With a declarative approach, you can easily see what the current system should look like.</p><p>In an imperative approach, if previous commands weren’t recorded, figuring out what was changed can be difficult. But in a declarative system, <strong>the code itself represents the intended state</strong>, making it much easier to manage.</p><p><strong>3. Better Version Control &amp; Rollback</strong></p><p>One of the biggest advantages of a declarative approach is how simple it makes <strong>rollback</strong>.</p><p>Since Kubernetes, GitOps tools like <strong>ArgoCD</strong>, and Terraform store state information, you can easily <strong>revert to a previous version</strong> when needed. Running terraform apply or kubectl apply ensures that the system automatically adjusts to match the defined configuration.</p><h3><strong>But Is the Declarative Approach Always Better?</strong></h3><p>Not necessarily. While the declarative approach offers consistency, automation, and version control, there are cases where <strong>the imperative approach is more practical</strong>.</p><ol><li><strong>When you need immediate execution</strong></li></ol><ul><li>If something is broken in production, you don’t have time to edit a YAML file or commit changes to Git.</li><li>A quick kubectl delete pod or aws restart-instance might be the fastest way to fix it.</li></ul><p><strong>2. When the task is simple and doesn’t need to be repeated</strong></p><ul><li>If it’s a <strong>one-time operation</strong>, defining an entire configuration file might be unnecessary.</li></ul><p>Neither approach is inherently better — it depends on the situation. In real-world DevOps workflows, <strong>you often use both approaches together</strong> rather than sticking to just one.</p><h3>Conclusion</h3><p>The declarative approach makes infrastructure <strong>consistent, automated, and easy to manage</strong>, which is why tools like <strong>GitOps, Kubernetes, and Terraform</strong> follow this model.</p><p>At the same time, the <strong>imperative approach is still valuable for quick, one-off tasks</strong> that don’t need automation or version control.</p><p>Understanding when to use each method is key to <strong>efficient and reliable infrastructure management</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=33c0d028bf4b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Isolation Mechanism of Linux Containers (1): Linux Namespace]]></title>
            <link>https://medium.com/@bo-yoon/isolation-mechanism-of-linux-containers-1-linux-namespace-4fac08ae9898?source=rss-c58206db6ddf------2</link>
            <guid isPermaLink="false">https://medium.com/p/4fac08ae9898</guid>
            <category><![CDATA[containers]]></category>
            <category><![CDATA[namespaces]]></category>
            <category><![CDATA[linux]]></category>
            <category><![CDATA[cloud]]></category>
            <dc:creator><![CDATA[boyoon]]></dc:creator>
            <pubDate>Mon, 18 Nov 2024 07:58:05 GMT</pubDate>
            <atom:updated>2024-11-18T08:56:18.824Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>9Isolation Mechanism of Linux Containers (1): Linux Namespace</strong></h3><p>If I were to name one technology that serves as the <strong>foundation of cloud technology</strong>, I would choose <strong>Linux containers</strong>. In this article, I’ll explore the isolation mechanisms that underpin container technology.</p><p>First, let’s consider the <strong>reasons why container technology emerged</strong> in the first place.</p><p>About a decade ago, most software applications were built as large, <strong>monolithic</strong> structures. Due to their size and complexity, updates were slow, and making changes was a significant challenge.</p><p>To address these issues, applications began to be broken down into smaller, independent units called <strong>microservices</strong>. These microservices could run independently, and breaking them into smaller components made development and deployment more flexible. However, this also introduced new challenges, as the number of components to manage increased.</p><p>Each application now needed to meet its own <strong>environmental requirements</strong>, and operating systems and libraries had to be meticulously managed. In this increasingly complex environment, <strong>container technology</strong> emerged as a solution.</p><h3><strong>What is a Container?</strong></h3><p>A container is a <strong>software package that includes everything needed to run an application in any environment</strong>.</p><p>Container technology allows multiple services to run on the same host system while providing isolated environments for each service. It is similar to a virtual machine in that it isolates resources but with significantly less overhead. A container includes code, libraries, and configuration files, enabling applications to run consistently across different environments.</p><p>How is this level of isolation achieved? It is made possible by <strong>two key mechanisms</strong>. This article will cover the first of these mechanisms: <strong>Linux Namespaces</strong>.</p><h3><strong>Linux Namespaces</strong></h3><p>The first mechanism is Linux namespaces. Linux namespaces ensure that each process can only see a <strong>separate, isolated view of the system</strong>. They are used to isolate specific resource groups, making it appear as though containers are running in their own independent environments.</p><p>When we say processes have an independent view, it means they cannot see or interfere with each other. Each namespace defines its own space, and objects in other namespaces cannot intrude into it. This isolation ensures that containers behave as though they are running on entirely separate systems.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lwQzeD0z0YH4wyzqRCWDHQ.png" /></figure><p>These Divided Namespaces Offer the Following Capabilities</p><h3><strong>Process Isolation (feat. PID Namespace)</strong></h3><p>The PID namespace isolates process IDs, allowing each namespace to have its own <strong>process tree</strong>. Even though the mapped host PIDs differ, each namespace maintains its own unique set of PIDs.</p><p>This prevents process conflicts and ensures an independent environment. When processes have their own PIDs, the resources used by these processes also need isolation. This is where the <strong>IPC namespace</strong> comes into play.</p><h3><strong>Inter-Process Communication Resource Isolation (feat. IPC Namespace)</strong></h3><p>IPC stands for <strong>Inter-Process Communication</strong>, a mechanism that allows processes to exchange data or collaborate on tasks. <strong>The IPC namespace</strong> in Linux isolates these communication resources by namespace.</p><p>With the IPC namespace, each namespace has its own <strong>shared memory, semaphores, and message queues</strong>. This means that even if a message queue is created in Namespace A, it remains invisible to Namespace B.</p><p>This ensures strict isolation and prevents interference between namespaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*X5siKd_BP-XRFoo30fjhZg.png" /></figure><h3><strong>Network Isolation (feat. NET Namespace)</strong></h3><p>The NET namespace allows each namespace to have its own <strong>unique network interfaces</strong>, such as IP addresses, routing tables, and firewall rules.</p><p>This capability ensures that the <strong>network environments</strong> of different namespaces or containers are completely isolated from one another. Each namespace operates as though it has its own private network, preventing interference and enabling independent configuration of network resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i85XFq8bvnd6HrNoAi1nXg.png" /></figure><p>What if Containers Need to Communicate with Each Other?</p><p>If containers need to communicate, they can use a <strong>bridge network</strong>.</p><h3><strong>Bridge Network</strong></h3><p>The <strong>bridge network</strong> is a Linux networking technology that acts as a <strong>virtual switch</strong>, allowing multiple network interfaces to communicate with each other. It connects the network interfaces of containers (or namespaces) to enable communication within the same bridge.</p><p>Using a bridge network, containers can communicate with other containers on the same bridge and also connect to external networks if needed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CeKiV1w-1vucJjtudZtaRg.png" /></figure><p>To summarize:</p><p>• <strong>Internal communication</strong>: Containers can communicate with each other (e.g., eth1 ↔ eth2) through the bridge.</p><p>• <strong>External communication</strong>: A container can connect to the internet via the bridge (e.g., eth1 ↔ bridge ↔ internet).</p><p>• <strong>Independent networks</strong>: If the bridge is not used, containers can operate in isolated, independent network environments.</p><h3><strong>Filesystem Isolation (feat. MNT Namespace)</strong></h3><p>Returning to the features of namespaces, the <strong>MNT namespace</strong> provides each namespace with its own unique view of the filesystem. This ensures that a namespace can access only the directories it is configured to see while being completely isolated from the filesystems of other namespaces.</p><p>For example, a container or namespace can only interact with its assigned directory structure, preventing unauthorized access to other namespaces’ filesystems. This isolation is crucial for security and maintaining independent environments.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*luCqXH9I64_TPaDRRgR-Hw.png" /></figure><p>This logic prevents file conflicts between containers. Since each container has its own independent filesystem, any filesystem issues occurring in one container do not affect others. This isolation ensures the integrity and stability of each container’s operations.</p><h3><strong>Host Information Isolation (feat. UTS Namespace)</strong></h3><p>After achieving isolation from a filesystem, network, and process perspective, it’s necessary to assign a <strong>unique identity</strong> to each isolated environment. This is where the <strong>UTS (Unix Time Sharing) namespace</strong> comes into play.</p><p>The UTS namespace allows each namespace to have a unique <strong>hostname</strong> and <strong>domain name</strong>. This is particularly useful for scenarios like setting up multiple test environments on a single physical server. By assigning a distinct hostname to each environment, you can prevent conflicts and ensure clear identification of namespaces.</p><p>For example, you can configure separate hostnames for different environments, like test1.local and test2.local, even if they run on the same physical machine. This simplifies management and enhances isolation.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vhSftMHv5sKc8jOPnz40Eg.png" /></figure><h3><strong>User Privilege Isolation (feat. USER Namespace)</strong></h3><p>The USER namespace is a technology that separates user IDs (UIDs) and group IDs (GIDs) by namespace. With this, processes inside a namespace can behave as if they have administrator (root) privileges, while appearing as a regular user outside the namespace. In other words, it looks like root inside the namespace but has safely restricted permissions on the host.</p><p>This allows administrative actions inside the namespace without affecting the host system. Each namespace can have its own independent users and groups, providing an isolated environment. For example, a process might have a UID 0 (root) inside the namespace, but on the host system, it maps to a UID 1001 as a regular user.</p><p>This concludes our exploration of <strong>Linux namespaces</strong>, one of the core mechanisms behind Linux container technology. In the next post, I’ll dive into another important mechanism: <strong>CGroup (Control Groups)</strong>!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4fac08ae9898" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[RAGOps 란?]]></title>
            <link>https://medium.com/@bo-yoon/ragops-%EB%9E%80-38d24f790670?source=rss-c58206db6ddf------2</link>
            <guid isPermaLink="false">https://medium.com/p/38d24f790670</guid>
            <category><![CDATA[devops]]></category>
            <category><![CDATA[ragops]]></category>
            <category><![CDATA[rags]]></category>
            <dc:creator><![CDATA[boyoon]]></dc:creator>
            <pubDate>Wed, 06 Nov 2024 11:18:34 GMT</pubDate>
            <atom:updated>2024-11-18T08:59:59.823Z</atom:updated>
            <content:encoded><![CDATA[<p>DevOps 로 근무 하다보면 뭐든 뒤에 Ops 가 달린것을 보면 흥미를 갖기 마련입니다. 다루는 대상에 따라 새롭고 챌린징한 기술을 경험할 수 있기 때문일것입니다. 그중 최근 제 관심을 사로잡은 것은 <strong>RAGOps</strong>입니다. 그래서 이번 글에서는 RagOps에 대한 제 지식을 더욱 확고히 다질겸 간단히 정리하는 글을 써볼까 합니다. 새로운 지식에 대한 접근을 목적으로 한 글이라 부족할 수 있으니 틀린 점을 발견하신다면 지적해주시면 감사하겠습니다.</p><h3>LLM (Large Language Model)</h3><p>먼저 RAGOps 대해서 알아보기 전에, RAG라는 개념이 나오기 된 베이스 기술중 하나인 LLM에 대해서 간단히 적어보겠습니다. 말 그대로 “대규모 언어 모델”이라는 의미를 가지고 있는 LLM은 사람의 언어를 이해하고 대답하는 인공지능 모델입니다. 이 모델은 인터넷이나 글에서 수많은 텍스트를 학습하여 단어와 문장 구조를 이해하고 또 문장을 생성하는 기능을 가지고 있습니다. 문장을 이해하고 있기 때문에 우리가 질문을 한다면 그에 맞는 대답을 해줄 수가 있습니다.</p><p>LLM은 2가지 과정으로 이루어지는데 Pre-Training과 Fine-Tuning입니다.</p><ul><li>Pre-Training은 엄청난 양의 text를 읽으며 모델이 언어의 구조와 패턴을 배우는 단계입니다. 이 과정에서 모델은 단어의 의미와 순서를 이해하게 되는데 예를 들어 “고양이는 귀여워” 라는 문장이 있다면 이를 학습에 고양이 뒤에 귀여워가 올 수 있다는 관계를 이해합니다. 이렇게 학습된 모델을 Pre-Training Model이라고 합니다.</li><li>Fine-Tuning은 앞서 만들어진 Pre-Training Model 을 좀더 목적에 맞게 미세 조정하는 단계입니다. 예를 들어 고객 문의에 좀더 잘 대답해야 하는 모델이 있다면 그목적에 맞게 대답하는 방식을 변경하는 작업을 뜻합니다. 이렇게 조정된 모델은 특정 작업에 특화되어 있습니다.</li></ul><p>단, 이런 LLM 모델의 단점이 하나 있는데 말그대로 사전학습된 모델이다 보니 최신 정보에 뒷떨어져 있다는 점이었습니다. 어제는 빨간머리였던 친구가 오늘은 염색해서 검정머리 일수 있는데 LLM 모델에서는 여전히 빨간 머리로 대답할 것입니다. 그래서 이 단점을 보완하기 위해 만들어진 방식이 바로 아래 정리할 RAG 입니다.</p><h3>RAG (Retrieval-Augmented Generation) 란?</h3><p>RAG는 <strong>AI가 필요한 정보를 검색해서 그 정보를 기반으로 답변을 만드는 방법</strong>입니다. LLM은 이미 배운 정보에 기반해 답을 하기 때문에 새로운 정보나 최신 데이터에 대한 답변이 어렵습니다. 하지만 RAG는 모델에 없어도 검색하고 찾아서 답변을 주기 때문에 최신 정보를 얻을 수 있습니다. 즉, 기존 LLM의 이해능력을 외부 지식 데이터 베이스에 연결해서 사용하는 것입니다.</p><p>RAG는 작게는 5가지의 과정, 혹은 크게 2가지 과정으로 나누어져 있습니다.</p><p>먼저 5가지의 과정에 대해서 말씀드리겠습니다.</p><ol><li><strong>input</strong> : 사용자의 질문이나 요청을 받는 단계입니다.</li><li><strong>Embedding &amp; Indexing</strong> : 질문과 관련된 문서를 백터로 전환하고 인덱싱하여 검색하기 좋게 저장하는 과정입니다.</li><li><strong>Retrieval</strong> : 백터 데이터페이스에서 질문과 관련된 문서를 검색하여 “Relevant Documents”를 찾는 단계입니다.</li><li><strong>Augmentation</strong> : 검색된 정보를 LLM에 추가하여 답변 생성에 필요한 참고 자료로 활용하는 단계입니다.</li><li><strong>Generation</strong> : 검색된 정보를 바탕으로 LLM이 최종 답변을 생성하는 단계입니다.</li></ol><p>이 5개의 과정은 크게 묶으면 2가지의 과정으로 변경될 수 있습니다.</p><ol><li><strong>Retrieval</strong> : 질문을 백터로 변환해 관련된 정보를 백터 데이터 베이스나 문서 저장소에서 검색합니다.</li></ol><ul><li><strong>Embedding</strong> : RAG는 질문을 숫자 백터로 변환하고, 데이터베이스에 저장된 문서도 백터로 변환하여 저장해둡니다. 이렇게 변환된 백터를 비교해 질문과 의미가 가장 비슷한 문서를 찾을 수 있습니다.</li><li><strong>Vector Database</strong> : 텍스트, 이미지, 오디오 등의 데이터를 백터(숫자 집합) 형태로 저장하고 유사한 데이터를 빠르게 검색할 수 있게 도와주는 데이터 베이스.</li><li><strong>유사도 기반 검색</strong> : 질문과 유사한 의미의 문서를 찾기 위해 유사도 계산(Similarity Calculation)을 진행합니다. 이때 사용하는 계산방식은 Cosine Similarity(두 백터의 방향)나 Euclidean Distance(백터 공간에서 직선 거리)입니다</li><li>2. <strong>Generation</strong> : 검색된 정보를 기반으로 LLM이 답변을 만드는 과정입니다. 이 과정에서 RAG는 검색된 문장을 그대로 사용하지 않고 질문에 맞게 답변을 만들어 줍니다.</li></ul><h3>RAGOps란?</h3><p>자 이제 RAG라는 단어에 대해서 알았습니다. 이제는 원래 목적인 RAGOps에 대해서 알아보겠습니다.</p><p>DevOps가 개발을 더 효과적이게 할 수 있는 기술과 방법론의 집합이라면, RAGOps도 마찬가지로 <strong>RAG를 더 효과적이게 할 수 있는 기술과 방법론의 집합</strong>입니다. RAGOps는 RAG 시스템의 성능과 관리 효율성을 극대화하는 것을 목표로 합니다.</p><p>Vector DB를 어떻게 관리할 것인지, 수많은 데이터를 가져오면서 발생하는 메모리, 디스크 부하나, 비용 관리는 어떻게 관리할것인지 복잡한 워크 플로우를 어떻게 관리할것인지 기술적으로 접근해야합니다. 그렇다면 RAGOps 에서는 어떤 것을 고려해야할까요?</p><h3>RAGOps 에서 고려해야 할 점</h3><p>RAGOps에서 고려해야 할 주요 사항들은 다음과 같습니다.</p><p>첫째, <strong>데이터 저장 및 관리</strong>입니다. RAG 시스템에서 중요한 요소인 Vector DB는 데이터의 정확성과 신속한 검색 성능을 보장하기 위해 꾸준히 관리되어야 합니다. 이를 위해 인덱싱 최적화, 백업, 복구 전략 등 데이터베이스 유지 관리 전략이 필요합니다.</p><p>둘째, <strong>리소스 효율성</strong>입니다. 대규모 데이터를 다루는 과정에서 메모리와 디스크 자원을 최적화하고, 관련 비용을 관리하는 것이 필수적입니다. 예를 들어, 자주 조회되지 않는 데이터를 적절히 보관하고, 필요한 순간에만 메모리에 로드하는 기술이 요구됩니다. 이를 통해 시스템 자원을 절약하고 성능을 최적화할 수 있습니다.</p><p>셋째, <strong>복잡한 워크플로우 관리</strong>입니다. RAG 시스템은 여러 단계의 처리 과정과 다양한 데이터 소스를 포함할 수 있으며, 각 프로세스가 원활하게 연결되고 실행될 수 있도록 워크플로우를 설계해야 합니다. 이를 통해 데이터 수집, 처리, 검색 단계가 효과적으로 관리되고, 사용자 요청에 빠르게 응답할 수 있습니다.</p><p>이처럼 RAGOps는 RAG 시스템의 성능과 운영 효율성을 극대화하기 위해 다양한 기술과 방법론을 적용하는 것이 중요합니다.</p><p>참고</p><ul><li><a href="https://www.promptingguide.ai/research/rag">https://www.promptingguide.ai/research/rag</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=38d24f790670" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Client side Apply VS Server side Apply (feat. argocd)]]></title>
            <link>https://medium.com/@bo-yoon/client-side-apply-vs-server-side-apply-feat-argocd-31512389930a?source=rss-c58206db6ddf------2</link>
            <guid isPermaLink="false">https://medium.com/p/31512389930a</guid>
            <category><![CDATA[declarative]]></category>
            <category><![CDATA[kubernetes]]></category>
            <category><![CDATA[argo-cd]]></category>
            <dc:creator><![CDATA[boyoon]]></dc:creator>
            <pubDate>Sat, 02 Nov 2024 08:09:33 GMT</pubDate>
            <atom:updated>2024-11-02T14:33:53.435Z</atom:updated>
            <content:encoded><![CDATA[<p>ArgoCD를 통해 기존 배포하던 오픈 소스 프로젝트를 마이그레이션 하는 과정을 진행하던 중, 해당 오픈 소스에서만 사용하는 CRD 가 기존 방식으로는 정상적으로 배포되지 않는 문제를 발견했습니다. 문제가 된 이유는 CRD의 네이밍이 너무 길어서 기존 ArgoCD에서 <strong>sync (동기화)</strong>를 수행할 수 없었기 때문입니다.</p><p><strong>[ 문제의 에러 ]</strong></p><pre>Too long must have at most 262144 bytes</pre><p>이 오류는 CRD의 크기 제한을 초과하여 발생한 것입니다.</p><p>이때 제가 해결항 방식은 argocd Application yaml 파일에 다음의 설정을 추가하는 것이었습니다.</p><p><strong>[ 해결 방법 ]</strong></p><pre>syncPolicy:<br>    syncOptions:<br>      - ServerSideApply=true</pre><p>그리고 다시 sync 버튼을 누르자 정상으로 반영되었습니다.</p><p>여기서 <strong>ServerSideApply</strong> 는 어떤 의미를 가지는 걸까요? 그리고 기존 방식으로 추정되는 <strong>ClientSideApply</strong> 방식으로는 왜 CRD 배포 시 에러가 발생했을까요? 이를 이해하기 위해서는 몇 가지 개념을 먼저 알아야 합니다.</p><h3>Service Discovery</h3><p>먼저 알아야 할 개념은 <strong>Service Discovery</strong> 입니다.</p><p><strong>Service Discovery</strong>는 분산 시스템이나 마이크로서비스 아키텍처에서 서비스들이 서로를 찾고 통신할 수 있도록 지원하는 메커니즘입니다. 마이크로서비스 환경에서는 각각의 서비스가 필요에 따라 동적으로 생성되거나 삭제되기 때문에, IP 주소나 포트가 지속적으로 변경됩니다. <strong>서비스 디스커버리</strong>는 이러한 동적 서비스를 자동으로 탐색하고, 서비스 간 연결을 쉽게 관리할 수 있도록 도와줍니다.</p><p>서비스가 특정 서비스에 접근할 필요가 있을 때(Look up), 대상 서비스의 위치를 조회해야 하는데, 이때 “디스커버리 메커니즘” 인 <strong>Client-Side Discovery</strong>와 <strong>Server-Side Discovery</strong> 두 가지 방식이 주로 사용됩니다.</p><h3>Client side Discovery VS Server side Discovery</h3><p><strong>Client-Side Discovery</strong></p><ul><li>Client가 직접 Service Registry 에서 서비스 위치를 조회해서 대상 서비스에 연결합니다. 클라이언트가 서비스 목록을 조회한 뒤 특정 알고리즘에 따라 해당 요청을 보낼 서비스 인스턴스를 선택합니다.</li><li>장점 : 네트워크 부하가 적고, 클라이언트가 직접 위치 정보를 조회하기 때문에 간단하고 효율적입니다.</li><li>단점 : 클라이언트가 서비스 레지스트리에 접근할 수 있어야 하고, 로드 밸런싱을 직접 처리해야 하기 때문에 클라이언트의 복잡성이 증가 할 수 있습니다.</li></ul><p><strong>Server-Side Discovery</strong></p><ul><li>Client가 로드 밸런서에 요청을 전달하면, 로드 밸런서가 Service Registry 에서 위치를 조회하여 적절한 서비스 인스턴스로 요청을 전달합니다.</li><li>장점 : 클라이언트는 로드 밸런서에만 요청을 보내도 되므로 구현이 간단합니다.</li><li>단점 : 로드 밸런서가 서비스 위치와 요청 분배를 모두 처리하기 때문에 로드 밸런서가 부하가 증가할 수 있습니다.</li></ul><p>쉽게 정리한다면 Cleint side Discovery는 Client가 Service Registry를 접근, Server Side Discovery는 Loadbalancer가 Service Registry를 접근하는 것입니다.</p><p>이제 Client side, Server side의 개념에 대해서 어느정도 알았으니, ArgoCD가 사용하는 sync 방식인 Client Side Apply 와 Server Side Apply 에 대해서 정리해보겠습니다.</p><h3>Client Side Apply vs Server Side Apply</h3><h3>Client Side Apply</h3><ul><li><strong>Client-Side Apply</strong>는 클라이언트가 로컬에서 리소스의 현재 상태와 새로 적용할 상태를 비교하여 변경된 부분을 계산한 후, 계산된 전체 리소스를 쿠버네티스 API 서버에 전송하여 적용하는 방식입니다.</li><li>이 방식은 <a href="http://kubectl.kubernetes.io/last-applied-configuration">kubectl.kubernetes.io/last-applied-configuration</a> 어노테이션을 사용하여 마지막으로 적용된 리소스의 전체 상태를 쿠버네티스 클러스터에 저장합니다. 이후 변경 사항이 발생하면 클라이언트가 상태를 비교하여 필요한 부분만 업데이트할 수 있습니다.</li><li>여기서 말하는 Client는 kubectl이나 ArgoCD를 의미합니다.</li><li>이 방식은 리소스의 전체 상태를 클라이언트에서 관리할 수 있어 클러스터와 독립적으로 상태를 추적하고 관리할 수 있다는 장점이 있지만, 리소스 크기가 커지면 어노테이션 크기 제한에 걸릴 수 있습니다. 또한 여러 클라이언트가 접근할 경우 충돌이 발생할 가능성도 있습니다.</li></ul><p>위에서 발생한 오류는 바로 이 <strong>어노테이션 크기 제한</strong>으로 인해 발생한 문제였습니다. 이를 해결하기 위해 <strong>Server-Side Apply</strong> 방식을 사용했으며, Server-Side 방식에서는 왜 문제가 발생하지 않는지 알아보겠습니다.</p><h3>Server Side Apply</h3><ul><li><strong>Server-Side Apply</strong>는 리소스의 상태 관리와 변경 사항 적용을 쿠버네티스 API 서버에서 처리하는 방식입니다. 클라이언트는 변경된 부분만 API 서버에 전송하며, 서버는 어노테이션 없이 상태를 추적합니다.</li><li>따라서 <strong>어노테이션 크기 제한이 없으므로</strong>, 대규모 리소스나 여러 클라이언트가 동일한 리소스를 관리하는 환경에서도 효과적입니다. 다만, 이 방식은 지원하는 클라이언트가 제한적일 수 있으며, Client-Side Apply에 비해 설정이 복잡해질 수 있습니다.</li><li>문제가 해결된 이유는 어노테이션에 상태를 저장하지 않고, 쿠버네티스 API 서버에서 직접 상태를 관리하도록 변경했기 때문입니다.</li></ul><p>정리하자면, <strong>Client-Side Apply</strong> 방식은 리소스의 상태를 어노테이션에 저장하기 때문에 크기 제한이 존재할 수밖에 없었고, 제가 배포한 CRD는 이 제한을 초과하여 문제가 발생했습니다. 이 문제를 해결하기 위해 <strong>Server-Side Apply</strong> 방식을 사용하였고, 이를 통해 쿠버네티스 API 서버에서 직접 상태를 관리하며 변경 사항을 적용하도록 설정하여 제한을 우회할 수 있었습니다.</p><p>따라서, 대규모 리소스나 어노테이션 크기 제한에 걸릴 가능성이 있는 리소스를 ArgoCD로 배포할 때는 <strong>Server-Side Apply</strong> 옵션을 사용하는 것이 효과적입니다. 이를 통해 ArgoCD는 더 안정적이고 유연하게 리소스를 동기화할 수 있습니다.</p><p>참고 ) argocd의 server side apply 에 대한 언급은 다음 문서에서 찾아 볼 수 있습니다.</p><p><a href="https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/">https://argo-cd.readthedocs.io/en/stable/user-guide/sync-options/</a></p><p>선언형 참고 )</p><p><a href="https://kubernetes.io/ko/docs/tasks/manage-kubernetes-objects/declarative-config/">https://kubernetes.io/ko/docs/tasks/manage-kubernetes-objects/declarative-config/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=31512389930a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[github action을 사용한 멀티 플랫폼 이미지 생성 방법]]></title>
            <link>https://medium.com/@bo-yoon/github-action%EC%9D%84-%EC%82%AC%EC%9A%A9%ED%95%9C-%EB%A9%80%ED%8B%B0-%ED%94%8C%EB%9E%AB%ED%8F%BC-%EC%9D%B4%EB%AF%B8%EC%A7%80-%EC%83%9D%EC%84%B1-%EB%B0%A9%EB%B2%95-69e2ee36c373?source=rss-c58206db6ddf------2</link>
            <guid isPermaLink="false">https://medium.com/p/69e2ee36c373</guid>
            <category><![CDATA[github-actions]]></category>
            <category><![CDATA[docker-image]]></category>
            <category><![CDATA[docker]]></category>
            <category><![CDATA[build]]></category>
            <category><![CDATA[graviton]]></category>
            <dc:creator><![CDATA[boyoon]]></dc:creator>
            <pubDate>Thu, 31 Oct 2024 06:55:28 GMT</pubDate>
            <atom:updated>2024-10-31T06:55:28.450Z</atom:updated>
            <content:encoded><![CDATA[<p>AWS에서 서비스를 운영 중이라면, 비용 절감과 성능 향상을 위해 Graviton 인스턴스를 도입해보려는 고민을 한 번쯤 해보셨을 겁니다. 마치 더 빠르고 효율적인 최신 컴퓨터를 원하듯, 저렴하면서도 성능이 뛰어난 인프라를 도입하고 싶은 마음은 누구나 같습니다. 그러나 이미 운영 중인 서비스의 아키텍처를 변경하는 것은 여러 가지 고려 사항이 따릅니다.</p><p>특히 컨테이너 이미지를 EC2나 Kubernetes 클러스터에서 구동 중인 경우, 먼저 해당 이미지가 ARM 아키텍처와 호환되는지 확인해야 합니다. 호환되지 않는다면 이미지를 ARM 아키텍처에 맞춰 다시 빌드해야 하는데, 이는 상당한 부담이 될 수 있습니다. 이를 해결하기 위해 <strong>멀티 플랫폼 이미지</strong>를 활용하면 다양한 아키텍처에서 동작할 수 있어 이러한 부담을 크게 줄일 수 있습니다.</p><p>멀티 플랫폼 이미지는 AMD64와 ARM64 등 서로 다른 아키텍처에서 사용할 수 있는 이미지를 하나로 통합한 것입니다. 이 이미지를 사용하면 동일한 이미지 태그로 여러 아키텍처를 지원할 수 있어, 추가 빌드 없이도 다양한 환경에서 호환성을 유지할 수 있습니다.</p><p>해당 이미지가 어떤 아키텍처와 호환되는지 아닌지는 아래 명령어를 통해 알 수 있습니다.</p><pre>docker manifest inspect {이미지 명: 태그 }</pre><pre>ex) docker manifest inspect newrelic/infrastructure-bundle:3.1.5</pre><pre>{<br>   &quot;schemaVersion&quot;: 2,<br>   &quot;mediaType&quot;: &quot;application/vnd.oci.image.index.v1+json&quot;,<br>   &quot;manifests&quot;: [<br>      {<br>         &quot;mediaType&quot;: &quot;application/vnd.oci.image.manifest.v1+json&quot;,<br>         &quot;size&quot;: 2586,<br>         &quot;digest&quot;: &quot;sha256:93f99a349a012&quot;,<br>         &quot;platform&quot;: {<br>            &quot;architecture&quot;: &quot;amd64&quot;,<br>            &quot;os&quot;: &quot;linux&quot;<br>         }<br>      },<br>      {<br>         &quot;mediaType&quot;: &quot;application/vnd.oci.image.manifest.v1+json&quot;,<br>         &quot;size&quot;: 2586,<br>         &quot;digest&quot;: &quot;sha256:2ec1c7130597ccf&quot;,<br>         &quot;platform&quot;: {<br>            &quot;architecture&quot;: &quot;arm64&quot;,<br>            &quot;os&quot;: &quot;linux&quot;<br>         }<br>      },</pre><h3>멀티플랫폼 이미지 빌드 방법</h3><p>먼저, 설명을 시작하기 전에 환경을 설명드리겠습니다.</p><ul><li>github action</li><li>aws ecr</li><li>docker buildx</li></ul><p>저는 github action을 통해 이미지를 빌드해서, ecr로 push 하는 시나리오로 테스트를 진행했습니다.</p><p>또 멀티플랫폼 이미지를 지원하기 위해 Docker Buildx 를 사용할 수 있습니다. buildx는 Docker의 확장 기능으로, 여러 아키텍처에 걸쳐 이미지를 빌드하고 push 할 수 있는 멀티플랫폼 빌드를 지원합니다. 따라서 buildx를 사용하면 AMD64와 ARM64 이미지를 한번에 빌드 할 수 있고, 단일 명령어로 레지스트리에 멀티 아키텍처 이미지를 push 할 수 있습니다.</p><h3>qemu 애뮬레이터 사용</h3><p>제가 사용한 방법은 QEMU 에뮬레이터를 사용하는 방법 입니다.</p><p>빌드 환경과 대상 플랫폼이 다른 경우 QEMU(Quick Emulator)를 사용할 수 있습니다. QEMU는 다양한 CPU 아키텍처를 에뮬레이션할 수 있는 오픈 소스 소프트웨어로, Docker buildx와 결합하면 호환되지 않는 플랫폼에서도 이미지를 빌드하고 테스트 할 수 있습니다. 예를 들어 AMD 환경에서도 ARM 이미지를 빌드 할 수 있도록 해주기 때문에 유용합니다. 하지만 단점이 있는데 바로 느리고 성능이 저하될 수 있습니다.</p><p>예시 )</p><p>github action 에 에뮬레이터 추가</p><p>docker buildx를 통해 빌드 과정 추가</p><pre>- name: Set up QEMU for multi-platform builds<br>    uses: docker/setup-qemu-action@v2<br>    with:<br>      platforms: linux/amd64,linux/arm64<br>  - name: Enable BuildKit<br>    shell: bash<br>    run: |<br>      export DOCKER_BUILDKIT=1<br>      docker buildx create --name multi-builder --driver docker-container<br>      docker buildx use multi-builder<br>      docker buildx inspect multi-builder --bootstrap<br>  - name: Build and push Docker image (multi-platform)<br>    shell: bash<br>    run: |<br>      docker buildx build --platform linux/amd64,linux/arm64 ${{ inputs.extra-build-args }} \\<br>        --build-arg BUILDKIT_STEP_MAX_PARALLEL=4 \\<br>        --cache-from type=registry,ref=${{ inputs.registry }}/${{ inputs.repository }}:buildcache \\<br>        --cache-to type=registry,ref=${{ inputs.registry }}/${{ inputs.repository }}:buildcache,oci-mediatypes=true,image-manifest=true \\<br>        -f ${GITHUB_WORKSPACE}/${{ inputs.dockerfile }} . \\<br>        --tag ${{ inputs.registry }}/${{ inputs.repository }}:latest \\<br>        --push</pre><p>테스트 결과, 기존 CI 구조를 크게 변경하지 않고도 멀티 플랫폼 이미지를 생성할 수 있었습니다. 다만, <strong>QEMU 에뮬레이터의 성능이 느린 편</strong>이라 최종적으로 Graviton 기반으로 전환한 후에도 멀티 플랫폼 이미지를 유지하지는 않았습니다. 대신, <strong>ARM 기반 러너로 변경해 빌드 속도와 비용 효율성을 개선</strong>하며 최적의 환경을 구축하게 되었습니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=69e2ee36c373" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[fluentd로 간단히 로그 수집해보기]]></title>
            <link>https://medium.com/@bo-yoon/fluentd%EB%A1%9C-%EA%B0%84%EB%8B%A8%ED%9E%88-%EB%A1%9C%EA%B7%B8-%EC%88%98%EC%A7%91%ED%95%B4%EB%B3%B4%EA%B8%B0-988ba8c161ae?source=rss-c58206db6ddf------2</link>
            <guid isPermaLink="false">https://medium.com/p/988ba8c161ae</guid>
            <category><![CDATA[fluentd]]></category>
            <category><![CDATA[logging]]></category>
            <dc:creator><![CDATA[boyoon]]></dc:creator>
            <pubDate>Mon, 21 Oct 2024 05:25:20 GMT</pubDate>
            <atom:updated>2024-10-21T05:25:43.444Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>fluentd는 오픈소스 데이터 수집기</strong>이자 로그 처리로 다양한 데이터 소스에서 데이터를 수집하고, 이를 원하는 형식으로 변경하여 저장소로 보내는 역할을 합니다. 주로 로그를 수집하고 처리하는데 사용됩니다</p><h3>특징</h3><ul><li>플러그인 기반 아키텍처 : fluentd는 필요한 기능에 관련된 플러그인을 추가해서 다양하게 확장 및 처리가 가능합니다. 예를 들어 기본 fluentd는 newrelic으로 데이터를 직접 보내는 기능을 제공하지 않지만, fluent-plugin-newrelic 를 통해 손쉽게 기능이 추가 가능합니다.</li><li>포맷 변환 : fluentd는 데이터를 입력받은 후 json, csv 등 다양한 형식으로 변경 가능합니다.</li><li>다양한 데이터 소스 : 또한 여러 데이터 소스를 통해 데이터를 수집후 통합할 수 있기 때문에 중앙 집중식 로그 서버로써 역할에 적합합니다. 그렇게 때문에 kubernetes, Docker와 같은 컨테이너 환경에서 로그를 수집하고 중앙화 된 클라우드 로그 분석 도구로 전송할 때 유용합니다.</li></ul><h3>fluentd의 이벤트 구조</h3><p>fluentd 이벤트는 fluentd 내부에서 로그 또는 데이터를 전송하고 처리하는 기본 단위입니다. fluentd는 데이터를 플러그인 사이에 전달할 때 이벤트라는 구조를 사용하여 데이터를 주고 받습니다.</p><ul><li>tag : 이벤트가 발생한 출처를 지정합니다. 즉, 이벤트를 구분하기 위한 식별자 입니다.</li><li>time : 이벤트가 발생한 시간을 지정합니다.</li><li>record : 실제 데이터를 json 형식의 구조화 된 데이터로 저장되며, 키 값 쌍으로 구성되어 있습니다.</li></ul><h3>fluentd 이벤트의 lifecycle</h3><p><a href="https://docs.fluentd.org/quickstart/life-of-a-fluentd-event">참고 문서</a></p><p>fluentd의 라이프 사이클은 총 5개의 단계로 나눠져 있습니다.</p><ul><li><strong>setup :</strong> fluentd의 전반적인 환경 설정을 의미합니다.</li><li><strong>inputs</strong> : 로그나 데이터를 수집하는 부분입니다.</li><li><strong>filters</strong> : 수집된 데이터를 가공하거나 변환하는 단계입니다. 이 단계에서 이벤트를 수락하거나 거부할 수도 편집할 수 도 있습니다.</li><li><strong>matches :</strong> 필터링 된 데이터를 특정 출력 대상으로 전송하는 단계입니다.</li><li><strong>labels :</strong> 여러 필터나 매치를 그룹화하여 구성요소를 재사용하거나 복잡한 라우팅 설정을 단순화 하는데 사용합니다.</li></ul><p>입니다.</p><h3>사용 방법</h3><p>: 도커 컴포즈를 사용하는 컨테이너 환경, fluend 1.14 버전 에서 사용하는 방법을 기준으로 합니다</p><p>우리는 손쉽게 <a href="https://hub.docker.com/r/fluent/fluentd/">도커 허브</a>에서 fluentd에 대한 도커이미지를 구할 수 있습니다. 그 이미지를 사용해 아래와 같이 도커 컴포즈 파일을 작성할 수 있습니다.</p><p>docker-compose.yaml</p><pre>version: &#39;3.6&#39;</pre><pre>services:<br>  fluentd:<br>    image: fluent/fluentd:v1.14-1<br>    ports:<br>      - &quot;24224:24224&quot;<br>    volumes:<br>      - ./fluentd.conf:/fluentd/etc/fluent.conf<br>      - ./logs:/var/log/docker<br>  service:<br>    container_name: testapp<br>    image: testapp:latest<br>    restart: always<br>    network_mode: host<br>    logging:<br>      driver: &quot;fluentd&quot;<br>      options:<br>        fluentd-address: &quot;localhost:24224&quot;<br>        tag: &quot;docker.testapp&quot;<br>    depends_on:<br>      - fluentd</pre><p>여기서 저는 docker의 로깅 드라이버를 사용해 fleund로 로그를 보내는 방식을 선택했습니다. docker 로깅드라이버는 컨테이너에서 생성된 로그를 다양한 방식으로 수집하고 처리하게 해주는 기능입니다. 각 컨테이너는 stdout과 stderr로그를 출력하는데 Docker는 이 로그를 로깅 드라이버를 통해 특정 대상에 저장하거나 전송합니다.</p><p>만약, 저희가 아무것도 세팅을 하지 않았다면 기본 값은 json-file 입니다. 즉, 각 컨테이너의 로그를 Json 파일 형식으로 로컬에 저장합니다. 이외에도 시스템 로그에 관련된 syslog , aws 클라우드 워치에 로그를 전송하는 awslogs가 있지만 이 중 이번에 사용 할 것은 fluentd 로 로그를 전송하는 fluentd 입니다. 도커 로깅 드라이버에 대한 자세한 설명은 <a href="https://docs.docker.com/engine/logging/configure/">이 문서</a>를 참조할 수 있습니다.</p><p>이제 fluentd 로깅 드라이버가 준비되었으니 필요한 것은 fluentd 설정 파일인 <strong>fluentd.conf</strong> 입니다.</p><p>fluentd.conf에 정의된 값으로 fluentd는 로그를 수집하고, 수정하여, 내보냅니다.</p><h3>파일로 내보내기</h3><p>먼저, 로그를 파일로 내보내는 것에 대한 설정입니다.</p><p>fluentd.conf</p><pre>&lt;source&gt;<br>  @type forward<br>  port 24224<br>  bind 0.0.0.0<br>&lt;/source&gt;</pre><pre>&lt;match docker.**&gt;<br>  @type file<br>  path &quot;/var/log/docker/testapp&quot;<br>  append true<br>  time_slice_format %Y%m%d<br>  compress gzip<br>  &lt;inject&gt;<br>    time_key time<br>    time_type string<br>    time_format &quot;%Y-%m-%d %H:%M:%S&quot;<br>    timezone Asia/Seoul<br>  &lt;/inject&gt;<br>&lt;/match&gt;</pre><p>먼저, 각각의 구성요소에 대해서 말씀드리겠습니다.</p><p><strong>source</strong></p><ul><li>데이터 수집 당하는 타겟을 정의합니다. 위의 fluentd 라이프 사이클에 input에 대응됩니다. <a href="https://docs.fluentd.org/input">source에 type으로 정의되는 설정은 총 9개</a>가 있지만, 이 중 이 테스트에서 사용할 기능은 forward입니다. forward는 fluentd 인스턴스 간에 데이터를 전송하고 수집하는데 사용됩니다. 이 케이스에서는 도커 로깅 드라이버를 통해 전송하기 때문에 fluentd로 하였습니다. 따라서, 저 source는 도커 로깅드라이버와 설정이 일치해야합니다. 만약, 로그를 어떤 경로에 저장하고, 그 파일의 끝만 읽어온다면 tail 을 사용할 수 있습니다.</li></ul><p><strong>match</strong></p><ul><li>matchs는 어떤 형식으로 데이터를 내보낼지에 대한 output입니다. 따라서, 위 설정에서는 파일 형식으로 내보내고, /var/log/docker/testapp 라는 경로에 시간 형식으로 데이터를 저장할 수 있습니다. 위 도커 컴포즈 파일을 보면 tag를 docker.testapp 로 내보냈기 때문에 docker.** 로 설정되어 있는 match에 맞는 데이터라 해당 데이터는 이쪽으로 출력됩니다.</li></ul><p><strong>inject</strong></p><ul><li>&lt;inject&gt;는 이벤트 처리 시 자동으로 특정 데이터를 삽입하는 기능을 제공합니다. 보통 로그를 처리할때 시간형식을 붙여서 어떤 시간에 발생했는지 추가해야 하는 경우가 있는데, 그 경우를 위해 추가하였습니다.</li></ul><pre>2024-10-17T08:00:41+00:00      test   {&quot;container_id&quot;:&quot;aaaa&quot;,&quot;container_name&quot;:&quot;/testapp&quot;,&quot;source&quot;:&quot;stdout&quot;,&quot;log&quot;:&quot;test&quot;,&quot;time&quot;:&quot;2024-10-17 17:00:41&quot;}</pre><h3>민감 정보 처리</h3><p>간혹, 로그를 수집할때 특정 정보는 마스킹이 처리한 경우가 있습니다. 이런 경우 fillter 를 사용합니다.</p><p>fluentd.conf</p><pre>&lt;source&gt;<br>  @type forward<br>  port 24224<br>  bind 0.0.0.0<br>&lt;/source&gt;</pre><pre>&lt;filter docker.**&gt;<br>  @type record_transformer<br>  enable_ruby<br>  &lt;record&gt;<br>    log ${record[&#39;log&#39;].gsub(/password=[^ ]+/, &#39;password=********&#39;)}<br>  &lt;/record&gt;<br>&lt;/filter&gt;</pre><pre>&lt;match docker.**&gt;<br>  @type file<br>  path &quot;/var/log/docker/testapp&quot;<br>  append true<br>  time_slice_format %Y%m%d<br>  compress gzip<br>  &lt;inject&gt;<br>    time_key time<br>    time_type string<br>    time_format &quot;%Y-%m-%d %H:%M:%S&quot;<br>    timezone Asia/Seoul<br>  &lt;/inject&gt;<br>&lt;/match&gt;</pre><p><strong>fliter</strong></p><ul><li>위 filter 설정은 record_transformer 라는 타입을 사용했습니다. 이 타입은 레코드를 변환하거나 필드를 추가하는 필터입니다. 따라서 위 설정은 password= 이라는 단어가 나오는 경우 ‘ ‘ 스페이스가 나올 때 까지 password=******** 로 변경한다 라는 의미입니다.</li><li>record_transformer 라는 타입를 사용하기 위해서는 enable_ruby 로 루비 코드를 켜줘야 합니다. 루비 코드를 사용해 복잡한 데이터 변환을 실행할 수 있으며 이 설정에서는 gsub 메서드를 사용해 텍스트를 치환합니다.</li><li>record_transformer 외에도 <a href="https://docs.fluentd.org/filter">필터 플러그인</a> 에서는 grep : 특정 문자가 있으면 잡아서 처리, parser : 이벤트 레코드를 구문 분석하고 결과에 따라 이벤트 레코드 변경 등 기능이 있으니 기능을 알고 싶다면 참조된 문서를 읽어보시기 바랍니다.</li></ul><pre>2024-10-17T08:00:41+00:00      test   {&quot;container_id&quot;:&quot;aaaa&quot;,&quot;container_name&quot;:&quot;/testapp&quot;,&quot;source&quot;:&quot;stdout&quot;,&quot;log&quot;:&quot;password=********&quot;,&quot;time&quot;:&quot;2024-10-17 17:00:41&quot;}</pre><ul><li>record_transformer 기능은 추가적으로 다른 레코드에서도 적용할 수 있습니다. 위 로그를 보면 container_name에 불필요하게 “/” 가 들어가 있는 것을 확인할 수 있습니다. 따라서, 아래 설정을 통해 “/” 를 제거 하였습니다.</li></ul><pre>&lt;filter docker.**&gt;<br>  @type record_transformer<br>  enable_ruby<br>  remove_keys source<br>  &lt;record&gt;<br>    log ${record[&#39;log&#39;].gsub(/password=[^ ]+/, &#39;password=********&#39;)}<br>    container_name ${record[&#39;container_name&#39;].gsub(&#39;/&#39;, &#39;&#39;)}<br>    server_name &quot;testapp&quot;<br>  &lt;/record&gt;<br>&lt;/filter&gt;</pre><ul><li>또한 remove_keys source 를 통해 &quot;source&quot;:&quot;stdout&quot; 이라는 불 필요한 레코드를 제거할 수도 있습니다.</li><li>마지막으로 server_name “testapp” 과 같이 하여 특정 레코드를 추가할 수도 있습니다.</li></ul><pre>2024-10-17T08:00:41+00:00      test   {&quot;container_id&quot;:&quot;aaaa&quot;,&quot;container_name&quot;:&quot;testapp&quot;,&quot;log&quot;:&quot;password=********&quot;,&quot;time&quot;:&quot;2024-10-17 17:00:41&quot;, &quot;server_name&quot;:&quot;testapp&quot;}</pre><h3>기본 지원하지 않는 플러그인 사용하기</h3><p>로그를 newrelic으로 보내서 수집하는 회사도 있을것입니다. 하지만, <a href="https://docs.fluentd.org/output">fluentd 의 output 플러그인</a>을 보면 newrelic이 지원 목록에 없는 것을 확인할 수 있습니다. 이럴 경우 외부 플러그인을 찾아 추가할 수 있습니다.</p><p>Dockerfile</p><pre>FROM fluent/fluentd:v1.14-1</pre><pre>USER root<br>RUN gem install fluent-plugin-newrelic<br>RUN gem install fluent-plugin-s3</pre><pre>USER fluent</pre><p>다음 도커파일을 빌드하고 docker-compose.yaml 파일의 fluentd이미지를 해당 이미지로 변경하고, 아래 newrelic에 대한 match를 추가해 fluentd를 다시 띄웁니다.</p><p>fluentd.conf</p><pre>&lt;source&gt;<br>  @type forward<br>  port 24224<br>  bind 0.0.0.0<br>&lt;/source&gt;</pre><pre>&lt;filter docker.**&gt;<br>  @type record_transformer<br>  enable_ruby<br>  remove_keys source<br>  &lt;record&gt;<br>    log ${record[&#39;log&#39;].gsub(/password=[^ ]+/, &#39;password=********&#39;)}<br>    container_name ${record[&#39;container_name&#39;].gsub(&#39;/&#39;, &#39;&#39;)}<br>    server_name &quot;testapp&quot;<br>  &lt;/record&gt;<br>&lt;/filter&gt;</pre><pre>&lt;match docker.**&gt;<br>  @type newrelic<br>  api_key &lt;&lt;newrelic 라이센스키&gt;&gt;<br>  base_uri &lt;https://log-api.newrelic.com/log/v1&gt;<br>  include_time_key true<br>  time_key time<br>  time_format %Y-%m-%d %H:%M:%S<br>  timezone Asia/Seoul<br>&lt;/match&gt;</pre><p>이러한 설정을 통해 New Relic과 같은 외부 서비스로 로그 데이터를 전송하고, 실시간 모니터링 및 분석을 할 수 있습니다. Fluentd는 오픈 소스라는 장점을 살려 수많은 플러그인을 통해 확장성이 뛰어나며, 다양한 요구사항에 맞춰 데이터를 처리할 수 있습니다. 다만, <strong>플러그인의 안정성과 보안</strong>에 주의해야 합니다. 검증되지 않은 플러그인은 시스템에 문제를 일으킬 수 있기 때문에, 신뢰할 수 있는 플러그인을 사용하는 것이 중요합니다.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=988ba8c161ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AWS RDS 인증서 교체]]></title>
            <link>https://medium.com/@bo-yoon/aws-rds-%EC%9D%B8%EC%A6%9D%EC%84%9C-%EA%B5%90%EC%B2%B4-89e7bb20b69e?source=rss-c58206db6ddf------2</link>
            <guid isPermaLink="false">https://medium.com/p/89e7bb20b69e</guid>
            <category><![CDATA[ssl-certificate]]></category>
            <category><![CDATA[aws]]></category>
            <dc:creator><![CDATA[boyoon]]></dc:creator>
            <pubDate>Tue, 23 Apr 2024 23:35:16 GMT</pubDate>
            <atom:updated>2024-04-23T23:35:54.048Z</atom:updated>
            <content:encoded><![CDATA[<h3>문제점</h3><p>: 인증서 업데이트가 필요한 데이터베이스 관련 경고 창이 뜨고 August 23, 2024 에 현재 사용중인 CA가 만료된다고 나온다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/912/1*NXlIgy-PEppwWeLgaNS5bQ.png" /></figure><h3>조치</h3><p>rds-ca-2019에서 rds-ca-rsa2048-g1로 CA 인증서를 업데이트</p><h3>Basic knowledge before work</h3><p><strong>SSL/TLS 인증서</strong></p><ul><li>Secure Sockets Layer와 Transport Layer Security 의 약자로 인터넷에서 데이터를 안전하게 전송하기 위해 사용되는 기술</li><li>SSL은 과거의 기술이고 현재는 TLS가 역할을 대신하고 있지만 여전히 SSL이라는 용어는 그대로 사용중이다.</li></ul><p><strong>주요 기능</strong></p><ul><li>암호화 : 인증서는 서버와 클라이언트 간의 통신을 암호화하여 제 3자가 정보를 읽을 수 없게 한다.</li><li>인증 : 해당 사이트가 실제 해당되는 기관이 운영하는 것인지를 사용자에게 보증한다.</li><li>데이터 무결성 : 통신 중에 데이터가 변경되거나 손상되지 않았는지를 확인</li></ul><p><strong>인증서 발급 과정</strong></p><ul><li>키 생성 : 웹 사이트 운영자는 공개 키와 개인 키를 생성한다. 개인 키는 비밀로 유지되며, 공개 키는 인증서에 포함됨.</li><li>CSR 생성 : 인증서 요청(Certificate Signing Request, CSR) 을 생성. CSR에서는 공개 키, 웹사이트 이름, 조직 정보 등이 포함됨.</li><li>인증서 발급 : CSR를 CA(Certificate Authority,인증 기관) 에게 제출하고, CA는 요청된 정보를 검증한 후 인증서를 발급한다. 이 인증서에는 웹사이트의 공개 키, CA의 서명, 유효 기간등이 포함된다.</li><li>인증서 설치 : 발급된 인증서를 웹 서버에 설치하여 사용자가 사이트에 접속할 때 SSL/TLS 를 통해 안전하게 통신할 수 있게 한다.</li></ul><h4>확인 할 것</h4><ol><li>엔진이 Restart 되는가?</li></ol><ul><li>Mysql 버전에 따라 restart가 될 수 있고 안될 수도 있음.</li><li>각 버전의 Mysql 버전 확인</li><li>그 버전의 Restart 여부 확인</li></ul><p>2. 애플리케이션 딴에서 인증서 업데이트를 해주어야 하는가</p><ul><li>일단 ssl 접속을 하는 중인가</li></ul><p>이 중 재시작 여부는 RDS &gt; 인증서 업데이트 부분에 나오지만 그래도 쿼리로 확인하려면 아래와 같다</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Mktt9JUTRTmFP1s_DZT2pw.png" /></figure><p>아래 쿼리를 사용하면 rds-ca-2019를 사용하는 DB인스턴스와 엔진 버전이 나온다</p><pre>aws rds describe-db-instances | jq -r &#39;.DBInstances[] | select(.CACertificateIdentifier == &quot;rds-ca-2019&quot;) | &quot;\(.DBInstanceIdentifier) \(.EngineVersion)&quot;</pre><p>다음 쿼리를 사용하면 해당 엔진 버전의 ‘ SupportsCertificateRotationWithoutRestart’ 이 True인지 False인지가 나온다.</p><p>이 옵션이 True가 나오면 Restart없이 인증서를 변경할 수 있고, 아니면 없다.</p><h3>방법</h3><p>RDS &gt; Database &gt; 해당 인스턴스 &gt; 수정</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uOdO_eg1wULVzJIUip0CAg.png" /></figure><p>그리고 즉시 적용을 눌러준다.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Xbt6Y_cYHDbrT21HF-Iww.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=89e7bb20b69e" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>