페이지

2021년 3월 27일 토요일

Kubernetes Config Files

 1. Thells Kubernetes about the different Deployments, Pods, and Services 
(referred to as 'Objects') that we want to create

 


2. Written in YAML syntax


3. Always store these files with our project source code - they are documentation!


4. We can create Objects without config files - do not do this. Config files 

provide a precise definition of what your cluster is running.


 Install MiniKube (https://kubernetes.io/docs/tasks/tools/install-minikube/)

minikube start


kubectl version


kubectl get all


kubectl apply -f first-pod.yaml


kubectl get all


minikube ip


kubectl describe pod webapp


kubectl exec webapp ls


kubectl -it exec webapp sh

wget http://localhost:80


cat index.html








kubernetes

 Kubernetes Cluster       => A collections of nodes + a master to manage them

 Node                        => A virtual machine that will run our containers

Pod                           => More or less a running container.

                                     Technically, a pod can run multiple containers

                                     (we won't do this)

Deployment                => Monitors a set of pods, make sure they are running

                                    and restarts them if they crash

Service                      => Provides an easy-to-remember URL to access 

                                    a running container


 



2021년 3월 26일 금요일

node js building docker

 FROM                  node:alpine       => Specify base image

 WORKDIR             /app                => Set the working directory to '/app' in the                                                                  container. All following commands will be 

                                                      issued relative to this dir

 COPY                   package.json ./   => Copy over only the package.json file

 RUN                    npm install        => Install all dependencies

 COPY                   ./ ./                 => Copy over all of our remaining source code

 CMD                    ["npm", "start"]  => Set the command to run when the container

                                                      starts up


Dockerfile


FROM node:alpine


WORKDIR /app

COPY package.json ./

RUN npm install

COPY ./ ./


CMD ["npm", "start"]




.dockerignore


node_modules


docker build .


Successfully built eb521ea6b7e6


docker run eb521ea6b7e6

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++


docker build -t abcdefg/efgh .            => Build an image based on the dockerfile in the 

                                                        current directory. Tag it as 'abcdefg/efgh'

docker run [image id or image tag]     => Create and start a container based on the

                                                        provided image id or tag

docker run -it [image id or image tag] [cmd] => Create and start container, but also

                                                                override the default command

docker ps                                    => Print out information about all of the 

                                                      running containers

docker exec -it [container id] [cmd]    => Execute the given command in a running 

                                                      container

docker logs [container id]                => Print out logs from the given container