Skip to content

NGINX Deployment materials

Syed Sayem edited this page Mar 29, 2019 · 1 revision

To process deployment you need to create two files:

  • deployment_file.yaml
  • index.html

Copy and paste this section to a file which you need to name: deployment_file.yaml

# **********************
# Deployment Definition
# **********************
 
apiVersion: apps/v1 # for versions before 1.9.0 use apps/v1beta2
kind: Deployment
metadata:
  name: nginx-deployment
spec:
  selector:
    matchLabels:
      app: nginx
  replicas: 10 # tells deployment to run 2 pods matching the template
  template: # create pods using pod definition in this template
    metadata:
      # unlike pod-nginx.yaml, the name is not included in the meta data as a unique name is
      # generated from the deployment name
      labels:
        app: nginx
    spec:
      containers:
      - name: nginx
        image: nginx:1.7.9
        volumeMounts:
          # What we gonna mount (SOURCE)
          - name: nginx-content-folder
          # Where we gonna mount it wihtin pod (container)
          # in Kubernetes1 (DESTINATION)
            mountPath: /usr/share/nginx/html
        ports:
        - containerPort: 80
      # Volumes specifications
      volumes:
        - name: nginx-content-folder
          configMap:
            name: nginx-content
 
---
# ******************
# Service Definition
# ******************
 
apiVersion: v1
kind: Service
metadata:
  labels:
    app: nginx
  name: nginx-deployment-service
  namespace: default
spec:
  ports:
  - nodePort: 30773
    port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx
  type: NodePort
 
 
############################

Please create configmap Kubernetes object. Copy and paste this HTML content to a file which you can name for example: index.html

In order to create a configmap object in Kubernetes you need to run:

kubectl create configmap nginx-content --from-file=/Users/sayem/Kubernetes/nginx/data/index.html
<!DOCTYPE html>

<html lang="en">
<head>
    <meta charset="UTF-8">

    <!-- Latest compiled and minified JavaScript -->
    <link rel="stylesheet"
          href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css"
          integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">

    <script src="https://code.jquery.com/jquery-3.2.1.slim.min.js"
            integrity="sha384-KJ3o2DKtIkvYIK3UENzmM7KCkRr/rE9/Qpg6aAZGJwFDMVNA/GpGFF93hXpG5KkN"
            crossorigin="anonymous"></script>
    <script
            src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.12.9/umd/popper.min.js"
            integrity="sha384-ApNbgh9B+Y1QKtv3Rn7W3mgPxhU9K/ScQsAP7hUibX39j7fakFPskvXusvfa0b4Q"
            crossorigin="anonymous"></script>
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/js/bootstrap.min.js"
            integrity="sha384-JZR6Spejh4U02d8jOt6vLEHfe/JQGiRRSQQxSfFWpi1MquVdAyjUar5+76PVCmYl"
            crossorigin="anonymous"></script>


    <!-- Fonts -->
    <link href="https://fonts.googleapis.com/css?family=Montserrat|Russo+One" rel="stylesheet">
    <!--
 font-family: 'Russo One', sans-serif;
 font-family: 'Montserrat', sans-serif;
 -->
    <title></title>
</head>
<body>

<div class="container-fluid">
    <div class="row">
        <div class="col-md-12">
            <nav class="navbar navbar-expand-lg navbar-light bg-light">

                <button class="navbar-toggler" type="button"
                        data-toggle="collapse"
                        data-target="#bs-example-navbar-collapse-1">
                    <span class="navbar-toggler-icon"></span>
                </button>
                <a class="navbar-brand" href="#">Brand</a>
                <div class="collapse navbar-collapse"
                     id="bs-example-navbar-collapse-1">
                    <ul class="navbar-nav">
                        <li class="nav-item active">
                            <a class="nav-link"
                               href="#">Link <span class="sr-only">(current)</span></a>
                        </li>
                        <li class="nav-item">
                            <a class="nav-link"
                               href="#">Link</a>
                        </li>
                        <li class="nav-item dropdown">
                            <a class="nav-link dropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink"
                               data-toggle="dropdown">Dropdo wn link</a>
                            <div class="dropdown-menu"
                                 aria-labelledby="navbarDropdownMenuLink">
                                <a
                                        class="dropdown-item"
                                        href="#">Action</a>
                                <a
                                        class="dropdown-item"
                                        href="#">Another
                                    action</a> <a
                                    class="dropdown-item"
                                    href="#">Something
                                else here</a>
                                <div
                                        class="dropdown-divide
r">
                                </div>
                                <a
                                        class="dropdown-item"
                                        href="#">Separated
                                    link</a>
                            </div>
                        </li>
                    </ul>
                    <form class="form-inline">
                        <input class="form-control mr-sm-2"
                               type="text"/>
                        <button class="btn btn-primary my-2 my-sm-0" type="submit">
                            Search
                        </button>
                    </form>
                    <ul class="navbar-nav ml-md-auto">
                        <li class="nav-item active">
                            <a class="nav-link"
                               href="#">Link <span class="sr-only">(current)</span></a>
                        </li>
                        <li class="nav-item dropdown">
                            <a class="nav-linkdropdown-toggle" href="http://example.com" id="navbarDropdownMenuLink"
                               data-toggle="dropdown">Dropdown link</a>
                            <div class="dropdown-menudropdown-menu-right"
                                 aria-labelledby="navbarDropdownMenuLink">
                                <a
                                        class="dropdown-item"
                                        href="#">Action</a>
                                <a
                                        class="dropdown-item"
                                        href="#">Another
                                    action</a> <a
                                    class="dropdown-item"
                                    href="#">Something
                                else here</a>
                                <div
                                        class="dropdown-divider">
                                </div>
                                <a
                                        class="dropdown-item"
                                        href="#">Separated
                                    link</a>
                            </div>
                        </li>
                    </ul>
                </div>
            </nav>
            <div class="jumbotron">
                <h2>
                    Hello, world!
                </h2>
                <p>
                    This is a template for a simple marketing or
                    informational website. It includes a large
                    callout called the hero unit and three
                    supporting pieces of content. Use it as a
                    starting point to create something more
                    unique.
                </p>
                <p>
                    <a class="btn btn-primary btn-large"
                       href="#">Learn more</a>
                </p>
            </div>
        </div>
    </div>
</div>
</body>
</html>