Skip to content

Latest commit

 

History

29 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

1h Crash Course Series Proceeding Order.

Docker Crash Course In 1h.

alt text

Tasks and notes from crash course. Made by TechWorld with Nana. Contains my own notes for not just watch videos.

Source.

Source Repository.

If the content sparked 🔥 your interest, please consider staring the course and start learning 📖.

Certification docker

Note: The material provided in this repository is only for helping those who may get stuck at any point of time in the course. It is very advised that no one should just copy the solutions(violation of Honor Code) presented here.

Additional stuff.

Progress/Curriculum

Intro and Course Overview.

  • We will be covering following:

alt text

What is docker.

alt text

  • Container is packed all the different parts inside.

What problems Docker solves in development and deployment process.

  • Before Docker, all developers needed to install their own setups of tools for their specific needs.
    • Os specific.
    • Configuration specific.
    • Etc.

alt text

alt text

  1. Setting up environment individually different to different OS.

alt text

  1. All these dependencies are inside container.
  2. As developer, you just need to execute one docker command and get docker container package docker run postgres.
  • Docker standardizes process of running any service on any local dev environment.
    • More time for development than setting up configuration.
    • With Docker, you can have same service running on local device whiteout any conflict.

alt text

alt text

  • With containers → DevOps team just needs to fetch and run Docker artifact.

alt text

  1. Different versions of same application. This is very difficult without docker.

alt text

  1. Old way was, develop and ship it to the DevOps team, which made configuration and installation. This was very error-prone.

alt text

alt text

  • There will be Docker Artifact which handles.

alt text

Virtual Machine vs Docker.

  • Big questions below.

alt text

alt text

  1. OS will be installing on the system, and it will communicate between different layers.

  2. Software will be on top of application layer. This will be communicating with the OS layer.

alt text

  • So the big question these both docker and vm are virtualization tools, so which layer these both virtualize.

alt text

  • Docker virtualize OS Application Layer.
  • Virtual machine virtualizes. OS Application Layer and OS kernel → Meaning virtualizes complete operating system.

alt text

  • What it means:
    • Docker image is, a couple of MB.
    • Dockers container takes seconds to start.
    • Dockers compatible only with Linux distros.
    • Vm images, a couple of GB.
    • Vm takes minutes to start.
    • Vm is running with all OS.

alt text

  1. Docker can't run Linux based docker image in Windows Host.
  • Docker Desktop.
    • Linux containers run on Windows or macOS.
    • This is solved with Hypervisor layer with small Linux distro. install Docker Desktop.

Install Docker.

  • Installing latest from docker website.

alt text

Docker Images vs Containers.

  • This image is like .zip and .jar file.

alt text

  • Docker images are like .jar a file packaged in containers.

    • It has compiled code.
    • It also has complete environment configuration.
      • Application, any services(Js app)(node, npm) needed, Os Layer(Linux).
    • Add env variables, create directories.
  • Docker Container is running image.

  • You can one you can run multiple container.

alt text

  1. Images can be run in containers
  • docker images Show what images we have locally

  • docker ps List running containers

Docker Registries.

  • There are images stored in Docker Register

  • Official images are available from applications like Redis, Mongo, Postgres etc.

    • There can be verified "Official" images or unofficial ones.
  • One the biggest docker register store is DockerHub

alt text

Docker Image Versions.

alt text

  • If you need specific version, you can choose specific docker image which has right tag
    • latest is the latest which was build

Pull and Run Docker containers.

  • To download image docker pull nginx:1.23

alt text

  • To list images docker images

  • Running images into container docker run nginx:1.23

    • With -d stop blocking
  • Docker generates random name automatically

alt text

Port Binding.

alt text

  • We need to expose container ports
    • This is done with Port Binding

alt text

  • You can see what ports containers are running in

alt text

  1. Port inside container
  2. Exposing port to local host
  • We can expose ports to localhost when creating container with special flag

alt text


alt text

  • We can publish ports when creating image with flag

docker run -d -p 9000:80 nginx:1.23

alt text

  • With following port structure

alt text


alt text

  1. After running with opening with following ports
    • We can see what is being mapped on

  • Now we can see its deployed into port 9000

alt text

  • To expose logs from docker

    • docker logs 6cb988ce6e05, where last one is docker id
  • It's standard to bind same port into container and which is exposed outside of container

Start and Stop containers.

  • Docker run always creates new container

  • To see all container which docker have created. You can use

docker ps -a

  • To start container you can use docker start {container} = start one or more stopped containers. Example docker logs 6cb988ce6e05

Private Docker Registries.

  • When companies, creates their own public private docker registries.

Registry vs Repository.


alt text

Dockerfile.

  • We want to build our docker image, when our application version is finished
    • We do this by writing "definition" how to build image
      • This is called docker file

alt text

  • Telling to build base image FROM base image

alt text

  • In docker file you can run Linux commands!

    • This is done with RUN directive
  • COPY copies files from src and adds them to containers path

  • WORKDIR /app changes working directly inside docker

  • Last command in docker file is CMD

alt text

Example of docker file.


FROM node:19-alpine

COPY package.json /app/
COPY src /app/

# COPY src /app/, last / is important. Docker will create new folder if there is no 

WORKDIR /app

RUN npm install

CMD ["node", "server.js"]

Build Image.

alt text


alt text

  • Building image docker build -t node-app:1.0 .
    • Last one is location of Dockerfile

alt text

  • You can see image is created in layers

  • We can run our newly created image docker run -d -p 3000:3000 node-app:1.0

  • We can see that our application inside docker is running and its being exposed to localhost:3000

alt text

Docker UI Client.

  • Same tool is found in UI.

alt text

Docker in complete software development lifecycle.

  • CI server can create docker image automatically

alt text

  1. After commit, CI server can be configured with to push and create docker image into Private Repository

Additional about docker.

  • We can connect docker app and MySQL with help of network

alt text

  1. When running docker container they are running in isolated networks
  • Listing all network docker network ls.

  • Creating docker network docker network create spring-net.

  • Connecting our container with given network docker network connect spring-net mysqldb.

  • Inspecting our container for attached networks docker container inspect mysqldb.

  • We can attach container to certain network when starting the container.

docker run -p 9090:8080 --name app --net spring-net -e MYSQL_HOST=mysqldb -e MYSQL_USER=root -e MYSQL_PASSWORD=root -e MYSQL_PORT=3306 app

Creating MySQL running in localhost container.

  • Starting and pulling and starting MySQL image docker run -d -p 3307:3306 --name mysqldb -e MYSQL_ROOT_PASSWORD=root -e MYSQL_DATABASE=user_rest_demo mysql.

  • To test connection localhost:3007 and configure allowPublicKeyRetrieval to true.

Docker Volume.

alt text

  • When restarting application data is lost, we can use volumes to keep data saved.

Learn Docker Compose In 1h.

alt text

Tasks and notes from crash course. Made by TechWorld with Nana.

Source

Source Repository

If the content sparked 🔥 your interest, please consider staring the course and start learning 📖

alt text

Note: The material provided in this repository is only for helping those who may get stuck at any point of time in the course. It is very advised that no one should just copy the solutions(violation of Honor Code) presented here.

Progress/Curriculum.

Intro and Course Overview.

  • We will cover:
    • What is Docker compose
    • What problems it solves?
    • Common Use cases
    • Hands-on demos
    • Limitations of Docker compose

Pre-Requisites to learn Docker Compose.

  • It's necessarily to know Docker containers before this one, if no Watch
    • It's advised to learn YAML format, if no Check

alt text

What is Docker Compose.

alt text

  1. Application can be broken into smaller pieces.
    • Or Microservice application.

alt text

  • All of these software components must be containerized and deployed/run together.
    • These services need to communicate together.
  1. We need some tool to control these actions:
    • Define and run multiple Services in 1 environment.
  • Each container is having own configuration and for this we can use Docker Compose, which makes our life easier.

Demo - Without Docker Compose.

  • Demo will have 2 Docker containers.
    • Just with Docker commands.
  1. Create Docker Network.
  2. Start MongoDB Container.
  3. Start Mongo Express Container(UI for MongoDB).
//Create mongo-network first
docker network create
 mongo-network

alt text

  1. We can see network is being created.

//List all networks
docker network ls

  • Running MongoDB in Docker.

    • You can see default ports from Docker Hub and default usernames and passwords.
  • For mongoDB.

docker run -d -p 27017:27017 -e MONGO_INITDB_ROOT_USERNAME=admin -e MONGO_INITDB_ROOT_PASSWORD=supersecret --network mongo-network --name mongodb mongo
  • For mongo-express.
    • Its just font-end for mongoDB.
docker run -d -p 8081:8081 -e ME_CONFIG_MONGODB_ADMINUSERNAME=admin -e ME_CONFIG_MONGODB_ADMINPASSWORD=supersecret -e ME_CONFIG_MONGODB_SERVER=mongodb --network mongo-network --name mongo-express mongo-express
  • To try if these work go to http://localhost:8081/ and log in
    • MongoDB depends on mongo-express and to communicate each other isolated virtual network must be configured and working!

Why Docker Compose.

alt text

  1. Problem comes when a lot of containers are needed to start and configure to communicate
  • We have one way to manage these → Docker Compose.
    • This is based on YAML File

alt text

From Docker Commands To Compose File.

  • Docker-Compose abstract all the CMD commands into docker-compose file.

alt text


alt text

  1. Required attributes for docker file!
    • First line, version of docker-compose which needs to be compatible with Compose is installed locally
  2. Services. List all services, you want to run

alt text

  1. YAML transfers this cmd commands to .YAML one configurable file
    • Here you can see one service being configured.
  2. Name of service being configured.

alt text

  1. Container name, this will map form command to

  2. From which image name docker container will be built from. You can specify version list

  3. List of ports which will be mapping to container.

    • Most time this you have only one mapping
      • 3.1 Host port and 3.2 port inside Container
  4. List of Environment variables for docker

alt text

  • As you can see another service is below other one!

alt text

  • This how the YAML will look like for previous example configuration.

  • *Docker Compose can help your team to collaborate more efficiently since, now they can see how these services can be run separately. Not just random cmd commands.

alt text

  1. You don't have to include network to YAML configuration. This will be taken care by default in docker compose
    • Docker takes care of creating docker network
      • From services from list

yaml

  1. When making YAML file be careful of indentation
  • Running YAML

Docker Compose Commands

  • We are trying to execute compose file
    • First we remove our old networks and containers
docker rm hashGoesHere // Removing container

docker network rm mongo-network // Removing docker network
  • If you have docker installed in your computer, you don't need to install Docker Compose

  • starting with docker compose

    • docker-build -f mongo-services.yaml up
      • up argument for running from up to down different services

alt text


alt text

  1. You can see how network names are created. 1. prefix from folder where .YAML was run.

Docker basically takes folder where it was executed and prefixes with names.

  • Docker logs are mixed since two containers were started at sane time.

Control Startup Order

  • When multiple services.

    • When we need db before front-end
  • This decency can be done using depends_on

    • This affects control of the services
    • This will start container only when dependencies are finished

alt text

  • Example using depends_on: in case of mongo-express:
  mongo-express:
    image: mongo-express
    ports:
     - 8081:8081
    environment:
      ME_CONFIG_MONGODB_ADMINUSERNAME=: admin
      ME_CONFIG_MONGODB_ADMINPASSWORD=: supersecret
      ME_CONFIG_MONGODB_SERVER=: mongodb
    depends_on:
      - "mongodb" # Takes list of services
  • Whole mongo-express service won't be started, before mongodb is up and running

  • Running following Compose in detach mode docker-compose -f mongo-services.yaml up -d

Docker Compose Commands (Up and Down vs Start and Stop)

  • We could stop containers using docker stop, but with big compose files this get problematic

alt text

  1. We can close all containers in the same time and remove them with following command docker-compose -f mongo-services.yaml down
    • This will clean networks, containers and docker images

alt text

  1. Data will be gone once container is removed
  2. Unless you define volumes

alt text

  1. Data will be lost when container is removed.
  2. Data will be saved.
  • These have different use cases.

Connect own web application.

  • Here we will add own app to our services

Variables in Docker Compose.

  • todo

Docker Compose Secrets.

  • todo

Use image from private repository.

  • todo

Limitations, Docker Compose vs Kubernetes.

  • todo

Kubernetes Crash Course for Absolute Beginners In 1h.

alt text

Tasks and notes from crash course. Made by TechWorld with Nana.

Source.

GitLab.

If the content sparked 🔥 your interest, please consider staring the course and start learning 📖.

alt text

Additional stuff.

Progress/Curriculum.

Intro and Course Overview.

  1. Introduction.
  2. Main components
  3. Setup.
  4. Demo project.

What is Kubernetes.

alt text

  1. There can be hundreds or thousands of containers.
  • What problems does Kubernetes solve?
  • What are the tasks of the orchestration tool?

alt text

  • What features orchestration tool offer?

alt text

  1. User can access is it fast!
  2. More load when more load.
  3. Backing up data, if something goes wrong.

Kubernetes Architecture.

alt text

  1. At least one master node.
  2. Worker Node referred as Nodes
    • These having kubelet process running on it.
      • This is part of Kubernetes, so these nodes can communicate with each other.
  3. Each work node has docker containers deployed on it!
  4. So what is running on master node? There is multiple kubernetes processes running here to manage the cluster.

alt text

  1. API Server, gateway to the K8 cluster.
    • 1.2 This gateway can be accessed thought UI, API or CLI.
  2. Keep overview what happening in cluster.
  3. Scheduling work and loads on node.
  4. etcd has status data of nodes and configurations. Back up process is made form these etcd configurations.

alt text

  1. Nodes are talking together with help of this Virtual Network.
    • Network turns nodes into one this big powerful machine.

alt text

  1. Most load will be on Worker Nodes, so these are most of time bigger.
  2. Master Node is much more important, once you lose Master Node, you will lose access to the kubernetes cluster.
  3. So you will have multiple masters for backup.

alt text

  1. Main components of Kubernetes.

Node and Pod.

alt text

  • Node is virtual or physical machine.
  1. Pod is smallest unit of Kubernetes.
    • Pod is abstraction over container.

alt text

  1. Pod is usually ment to run one container at the time.
    • It is possible to run multiple container inside one pod.
  2. Kubernetes has its own network, each pot get own IP address. Internal IP address.
  3. Pods are ephemeral!
    • pods can die easily.
  4. Pod will die to some here, and new one will get its place.
  • This new pod is having new IP address.

    • So, every time IP address are need to configure again!
  • This is where concept Service comes in!

Service & Ingress.

alt text

  1. Service can attach to pod, it will have own IP address.
  2. If pod dies, IP address of pod will stay! No need to change endpoint.

alt text

  1. App should be accessible from external sources. We we need open External Service.
  2. db should not be accessible from outside. Internal Service.

alt text

  • Ingress, will provide HTTPS and URL name for External Service.

ConfigMap & Secret.

alt text

  1. If the endpoint or service name will change, all of these needs to be ran.

alt text

  1. Kubernetes has ConfigMap, it will save all the URL data.
  2. You just point to this ConfigMap for URL.
  • Saving all the non-confidential data in ConfigMap is risky, that why there is Secret.

alt text

  1. Passwords and user names can be also configured.
  2. There is service called Secret which saves passwords and user in safe way. Kubernetes does not save these in save format. Kubernetes advices to use 3rd party tools to encrypt the passwords.
  3. We just need to connect this one to the pod.
  4. PRO TIP. We can use secret references in properties file or in env variable.
  • This Secret can have passwords, certificates and other things which needs to be encrypted.

Volume.

  • Whiteout Volumes data would be lost from db when restarted.

alt text

  1. Attaches hard drive to your pod or remote storage.
  • Now when database pod is restarted, all the data is persisted.

alt text

  1. Its admins job to handle kubernetes data into right place.

Deployment & StatefulSet.

  • We are replicating on pod in multiple servers.
    • In case if pod dies.

alt text

  1. Node being replicated and connected trough service.
  • Service having, permanent IP and load balancer.

alt text

  • For replicating pod we would.
  1. Define blueprint for Pods and use this blueprint for creating much of replicas as needed.
  • This is called deploy in Kubernetes components.

alt text

  • You will not be creating pods, you will be creating deployments.
    • In deployments you can scale down or up.

alt text

  1. When pod dies, other one will take its place.

alt text

  1. We can't replicate via Deployment!

alt text

  1. We need to control who access data inside db.
    • Mechanics needed which pod is reading or writing to the specific database .

alt text

  • statefulset kubernetes components.

alt text

  1. StatefulSet should be used when want to use of stateful features.
  • StatefulSet in usage of kubernetes cluster can be difficult.

  • DB are often hosted outside of Kubernetes cluster.

Summary, popular Kubernetes components.

alt text

alt text

alt text

alt text

  • These core components, we can build kubernetes clusters.

Kubernetes Configuration.

alt text

  1. All nodes which Kubernetes has goes trough API SERVER.

    • All of these requests can be made trough UI, API and CLI.
  2. Configuration for creating component called deployment.

  • Kubernetes configuration has three parts.

alt text

  • First part is metadata of component.

alt text

  • Second part is specifications. We put here configuration what we wan't to apply to that component.

alt text

  • spec are specific to the kind of configuration.

  • The Third part is a status.

alt text

  • Status is automatically generated and added by Kubernetes.

alt text

  • When Kubernetes notices difference between Desired and Actual state. Kubernetes tries to fix this using its self-recovery features.
    • Example here, we want two replicas of nginx deployment.

alt text

  1. Kubernetes will add here status of deployment and updates it constantly.

alt text

  1. If only one replica is detected to be running by comparing the specification.

  2. Another replica needs to be created ASAP .

alt text

  1. Where does K8 gets this status data?

alt text

  1. ETCD holds any data of k8 component! So, it also holds status data.

alt text

  • These configurations files are usually stored with you code.
    • Or own git repository.

Minikube and Kubectl - Setup K8s cluster locally.

alt text

  1. In production there is usually multiple Masters.
  2. There is also multiple Worker Nodes.
  3. These have all have separate responsibilities. Master and Node. So there will be separate virtual or physical machines, which each represent node.
  • Setting up cluster like this will be difficult, since it needs lot of resources.
    • CPU, Memory etc...

alt text

  • Minikube tool which has one node cluster. Which has master processes and Worker processes running inside one machine.

  • It has docker pre-installed.

alt text

  1. Kubectl is tool to interact with cluster.
    • Create pods or other k8 components.

alt text

  1. Api Server is main entry point to the K8 cluster.
  2. To talk to Api Server is trough different client. KUBECTL is most powerful of three clients.
  3. Once kubectl submits command to the server. Worker processes will make things happen.
    • Create pods ... etc.

alt text

  1. Kubectl can be used to interact with Minikube cluster or with Cloud cluster.
    • This can be interacted with any type of cluster type.
  • There are multiple ways to launch minikube.
    • One is Container.
    • Other is Virtual Machine.

alt text

alt text

  1. If minikube will be ran as Container.

    • You need driver installed as following, example. Docker.
  2. If minikube will be ran as Virtual Machine.

    • You need driver installed as following, example. VirtualBox.
  • Docker is recommended driver to be used with any situation.

alt text

  1. minikube comes with docker runtime and also driver for minikube where its hosted itself.
  • There will be layers of docker.

alt text

  • Starting minikube with driver. minikube start --driver docker.

  • Asking status. minikube status.

  • kubectl get installed as dependency when install minikube.

alt text

  1. We can get status of the nodes in the cluster. kubectl get node.

alt text

Complete Demo Project: Deploy WebApp with MongoDB.

alt text

  1. In cluster, we will have Webapp and Mongodb.
    • Which will get configurations form Secret and ConfigMap.

alt text

  1. We will crate 4 K8 configurations.
    • For ConfigMap.
    • For Secret.
    • Configurations for MongoDB.
    • Configuration for WebApp.
  • We can use kubernetes documentation. Example for config map format.

alt text

  • Example of ConfigMap.

alt text

  • Example of ConfigMap.
apiVersion: v1
kind: ConfigMap
metadata:
  name: mongo-config
data:
  mongo-url: mongo-service # This will be Service name of the MongoDB. This will be endpoint of MongoDB.

alt text

  • You can encode text using git bash echo -n mongopassword | base64.

    • These can be used for kubernetes secret.
  • Example of Secret.

apiVersion: v1
kind: Secret
metadata:
  name: mongo-secret
type: Opaque
data:
  mongo-user: bW9uZ291c2Vy
  mongo-password: bW9uZ29wYXNzd29yZA== 

alt text

  1. We can reference these from different deployments.

alt text

  1. template is Configuration for the Pod.
  2. containers you can have multiple containers within the pod.
  3. These are usually images form docker hub.

alt text

  1. In K8 you can label any component with the label.
    • Adds additional label for identification.

alt text

  1. When you have multiple replicas from same pod. Every Pod has unique name.
  2. These can share common label.
    • You can tell that these are shared form same pod.
  • Important. Every pod needs label!!

alt text

  • We use Selectors for identifying pod replicas for specific deployment.

  • Pods with nginx label which matches to the deployments label nginx, are grouped together.

  • Standard for naming labels is using app for given label.

    • Example. app: nginx.
  • replicas: 1 how many replicas we want from this deployment.

    • For database, we don't want to use deployment, we want stateful set.

alt text

  1. Service needs to forwards the request to specific pod.

alt text

alt text

  1. Port of where the request is coming into.
    • Port of the service.
  2. Which port request is forwarded into, port of the pod. targetPort should be containerPort.
    • Which port request is forwarded into in the pods
  • Example of Deployment configuration.
#  Deployment  & Service in one file.

apiVersion: apps/v1
kind: Deployment
metadata:
  name: mongo-deployment
  labels: # label for  deployment is optional, but recommended.
    app: mongo
spec:
  replicas: 1 # how many pods using this blueprint.
  selector:
    matchLabels:
      app: mongo # Standard is using app, and the label name.
  template:
    metadata:
      labels: # For pods this is required.
        app: mongo 
    spec:
      containers:
      - name: mongodb
        image: mongo:8.0 # We are using 5.0 image version.
        ports:
        - containerPort: 27017
  • Example of Service configuration.
# Service Configuration.

apiVersion: v1
kind: Service
metadata:
  name: mongo-service # This is name of the service, which is used to access mongo.
spec:
  selector: # Points to the Pod where this service belongs to.
    app: mongo # The label of the pod.
  ports:
    - protocol: TCP
      port: 9376 # Port of service. Standard these should be same.
      targetPort: 9376 # Port where to forward into. Standard these should be same.

alt text

  1. We need to pass Secret and CofigMap the pods.

alt text

  1. We are referring Secret like such.
  • We refer to ConfigMap with similiar way.
   - name: DB_URL
          valueFrom:
            configMapKeyRef:
              name: mongo-config
              key: mongo-url
  • We can use NodePort for making app accessible from external call.

alt text

  1. NodePorts are the port which will be opened to the K8 Nodes.

alt text

  • We have minicube cluster running, but there is now component running.

  • Getting pod kubectl get pod

    • Before this one need ConfigMap and Secret must be existing before Deployments.
  • We need components before referencing those components.

alt text

  • Deploying to the k8 with apply takes k8 file as input.
    • Following commands:
kubectl apply -f mongo-config.yaml
kubectl apply -f mongo-secret.yaml
kubectl apply -f mongo.yaml
kubectl apply -f webapp.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: webapp-deployment
  labels:
    app: webapp
spec:
  replicas: 1
  selector:
    matchLabels:
      app: webapp
  template:
    metadata:
      labels:
        app: webapp
    spec:
      containers:
      - name: webapp
        image: nanajanashia/k8s-demo-app:v1.0
        ports:
        - containerPort: 3000
        env:
        - name: USER_NAME
          valueFrom:
            secretKeyRef:
              name: mongo-secret
              key: mongo-user
        - name: USER_PWD
          valueFrom:
            secretKeyRef:
              name: mongo-secret
              key: mongo-password 
        - name: DB_URL
          valueFrom:
            configMapKeyRef:
              name: mongo-config
              key: mongo-url
---
apiVersion: v1
kind: Service
metadata:
  name: webapp-service
spec:
  type: NodePort
  selector:
    app: webapp
  ports:
    - protocol: TCP
      port: 3000
      targetPort: 3000
      nodePort: 30100

alt text

  • We only need to refer one Secret from many Deployments.

Interacting with Kubernetes Cluster.

  • All the components created form the cluster. kubectl get all
    • Example below.

alt text

  • For ConfigMap and Secret we need to use different commands.
    • kubectl get configmap.
    • kubectl get secret.

alt text

  • Example of using this commands for service kubectl describe service webapp-service.

alt text

  1. We can check logs from specific pod.
  • Delete kubectl delete deployments --all.

  • To get help. kubectl --help.

  • Which IP address we can access this service?

alt text

  1. We can access this from cluster IP address.
    • We can use minikube ip.

Congrats! You made it to the end.

  • Finish.

About

1h Course Series With Nana - Docker - Compose - Kubernetes.

Topics

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages