PageSourceSearch

https://owasp-kstg.netlify.app/kubernetes/deploying-app-using-manifest

html owasp-kstg.netlify.app collected 2026-10-03 11:14:12 UTC 17,237 bytes, 319 lines download raw bytes

1<!DOCTYPE HTML>
2<html lang="en" class="sidebar-visible no-js light">
3    <head>
4        <!-- Book generated using mdBook -->
5        <meta charset="UTF-8">
6<!-- This site is hosted on Netlify. Anyone can build and deploy a site
7     like this one for free: https://netlify.new/?utm_campaign=loops&utm_source=ai-legible&utm_medium=owned&utm_content=comment&utm_id=f581d32b-ec0e-4eb7-947f-3b42594baa5a
8     Netlify hosting facts for this site: static/SSR served via Netlify Edge. -->
9        <title>Deploying an application using manifest - Kubernetes Security Testing Guide</title>
10        
11
12        <meta content="text/html; charset=utf-8" http-equiv="Content-Type">
13        <meta name="description" content="">
14        <meta name="viewport" content="width=device-width, initial-scale=1">
15        <meta name="theme-color" content="#ffffff" />
16
17        <link rel="shortcut icon" href="../favicon.png">
18        <link rel="stylesheet" href="../css/variables.css">
19        <link rel="stylesheet" href="../css/general.css">
20        <link rel="stylesheet" href="../css/chrome.css">
21        <link rel="stylesheet" href="../css/print.css" media="print">
22
23        <!-- Fonts -->
24        <link rel="stylesheet" href="../FontAwesome/css/font-awesome.css">
25        <link href="https://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800" rel="stylesheet" type="text/css">
26        <link href="https://fonts.googleapis.com/css?family=Source+Code+Pro:500" rel="stylesheet" type="text/css">
27
28        <!-- Highlight.js Stylesheets -->
29        <link rel="stylesheet" href="../highlight.css">
30        <link rel="stylesheet" href="../tomorrow-night.css">
31        <link rel="stylesheet" href="../ayu-highlight.css">
32
33        <!-- Custom theme stylesheets -->
34        
35        <link rel="stylesheet" href="../css/custom.css">
36        
37
38        
39    </head>
40    <body>
41        <!-- Provide site root to javascript -->
42        
42<script type="text/javascript">
43            var path_to_root = "../";
44            var default_theme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "light" : "light";
45        </script>
45
46
47        <!-- Work around some values being stored in localStorage wrapped in quotes -->
48        
48<script type="text/javascript">
49            try {
50                var theme = localStorage.getItem('mdbook-theme');
51                var sidebar = localStorage.getItem('mdbook-sidebar');
52
53                if (theme.startsWith('"') && theme.endsWith('"')) {
54                    localStorage.setItem('mdbook-theme', theme.slice(1, theme.length - 1));
55                }
56
57                if (sidebar.startsWith('"') && sidebar.endsWith('"')) {
58                    localStorage.setItem('mdbook-sidebar', sidebar.slice(1, sidebar.length - 1));
59                }
60            } catch (e) { }
61        </script>
61
62
63        <!-- Set the theme before any content is loaded, prevents flash -->
64        
64<script type="text/javascript">
65            var theme;
66            try { theme = localStorage.getItem('mdbook-theme'); } catch(e) { }
67            if (theme === null || theme === undefined) { theme = default_theme; }
68            var html = document.querySelector('html');
69            html.classList.remove('no-js')
70            html.classList.remove('light')
71            html.classList.add(theme);
72            html.classList.add('js');
73        </script>
73
74
75        <!-- Hide / unhide sidebar before it is displayed -->
76        
76<script type="text/javascript">
77            var html = document.querySelector('html');
78            var sidebar = 'hidden';
79            if (document.body.clientWidth >= 1080) {
80                try { sidebar = localStorage.getItem('mdbook-sidebar'); } catch(e) { }
81                sidebar = sidebar || 'visible';
82            }
83            html.classList.remove('sidebar-visible');
84            html.classList.add("sidebar-" + sidebar);
85        </script>
85
86
87        <nav id="sidebar" class="sidebar" aria-label="Table of contents">
88            <div class="sidebar-scrollbox">
89                <ol class="chapter"><li class="chapter-item expanded "><a href='/introduction'><strong aria-hidden="true">1.</strong> Introduction</a></li><li class="chapter-item expanded "><a href='/kubernetes/introduction'><strong aria-hidden="true">2.</strong> Kubernetes Introduction</a></li><li><ol class="section"><li class="chapter-item expanded "><a href='/kubernetes/childrens-guide-to-kubernetes'><strong aria-hidden="true">2.1.</strong> The Children's Illustrated Guide to Kubernetes</a></li><li class="chapter-item expanded "><a href='/kubernetes/common-resources'><strong aria-hidden="true">2.2.</strong> High level overview of common resources</a></li><li class="chapter-item expanded "><a href='/kubernetes/playground'><strong aria-hidden="true">2.3.</strong> Creating a playground with Katacoda</a></li><li class="chapter-item expanded "><a href='/kubernetes/hands-on-usecases'><strong aria-hidden="true">2.4.</strong> Hands-on common use-cases</a></li><li><ol class="section"><li class="chapter-item expanded "><a class='active' href='/kubernetes/deploying-app-using-manifest'><strong aria-hidden="true">2.4.1.</strong> Deploying an application using manifest</a></li></ol></li></ol></li><li class="chapter-item expanded "><a href='/threat-model/introduction'><strong aria-hidden="true">3.</strong> Threat Model</a></li><li><ol class="section"><li class="chapter-item expanded "><a href='/threat-model/terminology'><strong aria-hidden="true">3.1.</strong> Terminology</a></li><li class="chapter-item expanded "><a href='/threat-model/actors'><strong aria-hidden="true">3.2.</strong> Threat Actors</a></li><li class="chapter-item expanded "><a href='/threat-model/trust-boundaries'><strong aria-hidden="true">3.3.</strong> Trust Boundaries</a></li><li class="chapter-item expanded "><a href='/threat-model/system-architecture'><strong aria-hidden="true">3.4.</strong> System Architecture</a></li><li class="chapter-item expanded "><a href='/threat-model/how-to-use'><strong aria-hidden="true">3.5.</strong> Using the Threat Model</a></li></ol></li><li class="chapter-item expanded "><a href='/security-testing/'><strong aria-hidden="true">4.</strong> Kubernetes Security Testing</a></li><li><ol class="section"><li class="chapter-item expanded "><a href='/security-testing/discovery/'><strong aria-hidden="true">4.1.</strong> Discovery</a></li><li><ol class="section"><li class="chapter-item expanded "><a href='/security-testing/discovery/fingerprint-master'><strong aria-hidden="true">4.1.1.</strong> Fingerprinting Master Node</a></li><li class="chapter-item expanded "><a href='/security-testing/discovery/fingerprint-worker'><strong aria-hidden="true">4.1.2.</strong> Fingerprinting Worker Node</a></li><li class="chapter-item expanded "><a href='/security-testing/discovery/'><strong aria-hidden="true">4.1.3.</strong> Cluster Exposed Service Discovery</a></li></ol></li><li class="chapter-item expanded "><a href='/security-testing/auth/'><strong aria-hidden="true">4.2.</strong> Authentication and Authorization Testing</a></li><li class="chapter-item expanded "><a href='/security-testing/cluster/'><strong aria-hidden="true">4.3.</strong> Cluster Testing</a></li><li class="chapter-item expanded "><a href='/security-testing/container/'><strong aria-hidden="true">4.4.</strong> Container Testing</a></li><li class="chapter-item expanded "><a href='/security-testing/runtime/'><strong aria-hidden="true">4.5.</strong> Runtime Testing</a></li></ol></li><li class="chapter-item expanded "><a href='/cis-benchmark/kubernetes'><strong aria-hidden="true">5.</strong> CIS Benchmark Audit for Kubernetes</a></li><li class="chapter-item expanded "><a href='/cis-benchmark/docker'><strong aria-hidden="true">6.</strong> CIS Benchmark Audit for Docker</a></li><li class="chapter-item expanded "><a href='/references-resources/'><strong aria-hidden="true">7.</strong> References &amp; Resources</a></li></ol>
90            </div>
91            <div id="sidebar-resize-handle" class="sidebar-resize-handle"></div>
92        </nav>
93
94        <div id="page-wrapper" class="page-wrapper">
95
96            <div class="page">
97                
98                <div id="menu-bar-hover-placeholder"></div>
99                <div id="menu-bar" class="menu-bar sticky bordered">
100                    <div class="left-buttons">
101                        <button id="sidebar-toggle" class="icon-button" type="button" title="Toggle Table of Contents" aria-label="Toggle Table of Contents" aria-controls="sidebar">
102                            <i class="fa fa-bars"></i>
103                        </button>
104                        <button id="theme-toggle" class="icon-button" type="button" title="Change theme" aria-label="Change theme" aria-haspopup="true" aria-expanded="false" aria-controls="theme-list">
105                            <i class="fa fa-paint-brush"></i>
106                        </button>
107                        <ul id="theme-list" class="theme-popup" aria-label="Themes" role="menu">
108                            <li role="none"><button role="menuitem" class="theme" id="light">Light (default)</button></li>
109                            <li role="none"><button role="menuitem" class="theme" id="rust">Rust</button></li>
110                            <li role="none"><button role="menuitem" class="theme" id="coal">Coal</button></li>
111                            <li role="none"><button role="menuitem" class="theme" id="navy">Navy</button></li>
112                            <li role="none"><button role="menuitem" class="theme" id="ayu">Ayu</button></li>
113                        </ul>
114                        
115                        <button id="search-toggle" class="icon-button" type="button" title="Search. (Shortkey: s)" aria-label="Toggle Searchbar" aria-expanded="false" aria-keyshortcuts="S" aria-controls="searchbar">
116                            <i class="fa fa-search"></i>
117                        </button>
118                        
119                    </div>
120
121                    <h1 class="menu-title">Kubernetes Security Testing Guide</h1>
122
123                    <div class="right-buttons">
124                        <a aria-label='Print this book' href='/print' title='Print this book'>
125                            <i id="print-button" class="fa fa-print"></i>
126                        </a>
127                        
128                    </div>
129                </div>
130
131                
132                <div id="search-wrapper" class="hidden">
133                    <form id="searchbar-outer" class="searchbar-outer">
134                        <input type="search" name="search" id="searchbar" name="searchbar" placeholder="Search this book ..." aria-controls="searchresults-outer" aria-describedby="searchresults-header">
135                    </form>
136                    <div id="searchresults-outer" class="searchresults-outer hidden">
137                        <div id="searchresults-header" class="searchresults-header"></div>
138                        <ul id="searchresults">
139                        </ul>
140                    </div>
141                </div>
142                
143
144                <!-- Apply ARIA attributes after the sidebar and the sidebar toggle button are added to the DOM -->
145                
145<script type="text/javascript">
146                    document.getElementById('sidebar-toggle').setAttribute('aria-expanded', sidebar === 'visible');
147                    document.getElementById('sidebar').setAttribute('aria-hidden', sidebar !== 'visible');
148                    Array.from(document.querySelectorAll('#sidebar a')).forEach(function(link) {
149                        link.setAttribute('tabIndex', sidebar === 'visible' ? 0 : -1);
150                    });
151                </script>
151
152
153                <div id="content" class="content">
154                    <main>
155                        <h1><a class="header" href="#deploying-simple-application-in-kubernetes-cluster-using-yaml" id="deploying-simple-application-in-kubernetes-cluster-using-yaml">Deploying simple application in Kubernetes Cluster using YAML</a></h1>
156<ul>
157<li>To create a basic nginx deployment with 2 replicas, save this file as <code>nginx-deployment.yaml</code> using your text editor</li>
158</ul>
159<pre><code class="language-yaml">apiVersion: apps/v1
160kind: Deployment
161metadata:
162  name: nginx-deployment
163spec:
164  selector:
165    matchLabels:
166      app: nginx
167  replicas: 2
168  template:
169    metadata:
170      labels:
171        app: nginx
172    spec:
173      containers:
174      - name: nginx
175        image: nginx:1.7.9
176        ports:
177        - containerPort: 80
178</code></pre>
179<ul>
180<li>Run the apply command to perform the changes in cluster</li>
181</ul>
182<pre><code class="language-bash">kubectl apply -f nginx-deployment.yaml
183</code></pre>
184<ul>
185<li>Get the pods related to this deployment</li>
186</ul>
187<pre><code class="language-bash">kubectl get pods --selector app=nginx
188</code></pre>
189<p><img src="images/deploy-app-get-pods.png" alt="" /></p>
190<ul>
191<li>Update the deployment file with <code>replicas</code> to 3 in <code>nginx-deployment.yaml</code> using your text editor</li>
192</ul>
193<pre><code class="language-yaml">...
194  replicas: 3
195...
196</code></pre>
197<ul>
198<li>Apply the changes</li>
199</ul>
200<pre><code class="language-bash">kubectl apply -f nginx-deployment.yaml
201kubectl get pods --selector app=nginx
202</code></pre>
203<p><img src="images/update-deployment.png" alt="" /></p>
204<ul>
205<li>Expose a service within the cluster</li>
206<li>Create a file <code>nginx-service.yml</code> with the following content</li>
207</ul>
208<pre><code class="language-yaml">apiVersion: v1
209kind: Service
210metadata:
211  name: nginx-deployment
212spec:
213  ports:
214  - port: 80
215    protocol: TCP
216    targetPort: 80
217  selector:
218    app: nginx
219  type: ClusterIP
220</code></pre>
221<ul>
222<li>Create the service in the cluster</li>
223</ul>
224<pre><code class="language-bash">kubectl apply -f nginx-service.yml
225</code></pre>
226<ul>
227<li>Start a <code>port-foward</code> to access in-cluster service</li>
228</ul>
229<pre><code class="language-bash">kubectl port-forward svc/nginx-deployment 8888:80
230</code></pre>
231<ul>
232<li>From another terminal, access the service through the port forward</li>
233</ul>
234<pre><code class="language-bash">curl http://localhost:8888/
235</code></pre>
236<ul>
237<li>Delete the deployment</li>
238</ul>
239<pre><code class="language-bash">kubectl delete -f nginx-deployment.yaml
240</code></pre>
241<p><img src="images/delete-deploy.png" alt="" /></p>
242<ul>
243<li>Delete the service</li>
244</ul>
245<pre><code class="language-bash">kubectl delete -f nginx-service.yml
246</code></pre>
247<h3><a class="header" href="#references" id="references">References</a></h3>
248<ul>
249<li><a href="https://kubernetes.io/docs/tasks/run-application/run-stateless-application-deployment/">https://kubernetes.io/docs/tasks/run-application/run-stateless-application-deployment/</a></li>
250</ul>
251
252                    </main>
253
254                    <nav class="nav-wrapper" aria-label="Page navigation">
255                        <!-- Mobile navigation buttons -->
256                        
257                            <a aria-keyshortcuts='Left' aria-label='Previous chapter' class='mobile-nav-chapters previous' href='/kubernetes/hands-on-usecases' rel='prev' title='Previous chapter'>
258                                <i class="fa fa-angle-left"></i>
259                            </a>
260                        
261
262                        
263                            <a aria-keyshortcuts='Right' aria-label='Next chapter' class='mobile-nav-chapters next' href='/threat-model/introduction' rel='next' title='Next chapter'>
264                                <i class="fa fa-angle-right"></i>
265                            </a>
266                        
267
268                        <div style="clear: both"></div>
269                    </nav>
270                </div>
271            </div>
272
273            <nav class="nav-wide-wrapper" aria-label="Page navigation">
274                
275                    <a aria-keyshortcuts='Left' aria-label='Previous chapter' class='nav-chapter
275s previous' href='/kubernetes/hands-on-usecases' rel='prev' title='Previous chapter'>
276                        <i class="fa fa-angle-left"></i>
277                    </a>
278                
279
280                
281                    <a aria-keyshortcuts='Right' aria-label='Next chapter' class='nav-chapters next' href='/threat-model/introduction' rel='next' title='Next chapter'>
282                        <i class="fa fa-angle-right"></i>
283                    </a>
284                
285            </nav>
286
287        </div>
288
289        
290
291        
292
293        
294        
295        
296        
296<script type="text/javascript">
297            window.playpen_copyable = true;
298        </script>
298
299        
300
301        
302
303        
304        
304<script src="../elasticlunr.min.js" type="text/javascript" charset="utf-8"></script>
304
305        
305<script src="../mark.min.js" type="text/javascript" charset="utf-8"></script>
305
306        
306<script src="../searcher.js" type="text/javascript" charset="utf-8"></script>
306
307        
308
309        
309<script src="../clipboard.min.js" type="text/javascript" charset="utf-8"></script>
309
310        
310<script src="../highlight.js" type="text/javascript" charset="utf-8"></script>
310
311        
311<script src="../book.js" type="text/javascript" charset="utf-8"></script>
311
312
313        <!-- Custom JS scripts -->
314        
315
316        
317
318    </body>
319</html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.