Intro : overried ENTRYPOINT of a DOcker image in k8s We can overried ENTRYPOINT value in a Docker image with command argumanet. CMD can’t be overwrrided by command argument. We have to use args argument instead.
https://kubernetes.io/docs/tasks/inject-data-application/define-command-argument-container/
Here is an official sample.
pods/commands.yaml apiVersion: v1 kind: Pod metadata: name: command-demo labels: purpose: demonstrate-command spec: containers: - name: command-demo-container image: debian command: ["printenv"] args: ["HOSTNAME", "KUBERNETES_PORT"] restartPolicy: OnFailure Inject environment variable In container section, add env.
ReplicationController No more details than official document.
https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/
It enables HA, auto scaling, multi node controll (across nodes). This is the first fancy function in k8s!!
ReplicaSet ReplicaSet is kind of newer version of ReplicationController.
https://kubernetes.io/docs/concepts/workloads/controllers/replicationcontroller/#replicaset
In stead of ReplicationController and ReplicaSet, we create “Deployment” object to manage Pods. Actually, Deployment use ReplicaSet and when we create a Deployment it creates ReplicaSet automatically.
Labels and Selectors By labels, Selectors can select the Pod which should be monitored by the Selector.
Service type https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types
ClusterIP NodePort LoadBalancer ExternalName ClusterIP https://d33wubrfki0l68.cloudfront.net/e351b830334b8622a700a8da6568cb081c464a9b/13020/images/docs/services-userspace-overview.svg
Internal network in the node. Use at first for ingress test.
NodePort Bind a port of node and forward it.
TargetPort: port on pod. Port: A Port from Service (to Deployments.) NodePort: A port on the node. selector: labels of the pods It calls “Node"Port but NodePorts can proxy pass to other nodes. It opens all worker node port.
Loadbalaner For cloud provider.
Namespace As I worte before, namespace is kind of logical boundary. Normaly, objects in namesapce A can’t communicate with objects in namespace B. So far, all objects are deployed in namespace default. We tagged name to a objects, and in the same namespaces object can be refered by its name label.
Create a namespace kubectl create namespace dev # change namespace permanently kubectl config set-context $(kubectl config current-context) --namespace=dev # My note kubectl config current-context #microk8s Or we can define namespace in YAML file also.
Environment Please refer to the set up memo .
I suppose you are already familiar to Docker image.
K8s basic concepts In k8s environment, there are a few concepts we should know before starting.
“INTRODUCTION TO KUBERNETES” from AWS is a conprehensive article.
note. Architecture: https://eksworkshop.com/010_introduction/architecture/architecture_control_and_data_overview/
K8s objects While creating your own k8s environment, you create and delete a lot of types of objects, such as,
Pod ReplicaSet Deployment Service Namespace and so on.
Pre-requirement of this post Host OS: Ubuntu18.04 snapd is install (for snapcraft.) Kubernetes is abbreviated as k8s. For single host k8s environment, there is a good k8s implementation called microk8s. I’ll use it. Setup on Ubuntu Install Docker and microk8s Install softwares, Docker and microk8s.
sudo snap install docker sudo snap install microk8s --classic --channel=1.18/stable Granting permission
sudo usermod -a -G microk8s $USER sudo chown -f -R $USER ~/.kube After re-login, check the k8s status.
Install jellybeans I use a color scheme called “Jellybeans”.
mkdir ~/.vim cd ~/.vim sudo yum install -y git git clone https://github.com/nanotech/jellybeans.vim mkdir colors mv jellybeans.vim/colors/jellybeans.vim ~/.vim/colors/jellybeans.vim vim ~/.vimrc colorscheme jellybeans set expandtab set tabstop=2 set softtabstop=2 set shiftwidth=2 set number syntax on set t_Co=256 set foldmethod=syntax Add the line into ~/.bashrc,
TERM=xterm-256color vim plugin manager https://github.com/junegunn/vim-plug/wiki/tips#automatic-installation
Add the following in .vimrc:
let data_dir = has('nvim') ? stdpath('data') . '/site' : '~/.
Check your network When you deploy your docker container with port mapping, the network is automatically generated and the container assigned its own network.
atlex@ ~ % docker network ls NETWORK ID NAME DRIVER SCOPE ea37d3b97d11 bridge bridge local 01573b79ea81 host host local 85b9bca4df78 none null local 0abac39fbea3 dockerfiletest bridge local` Details
atlex@ ~ % docker network inspect dockerfiletest [ { "Name": "dockerfiletest_default", "Id": "0abac39fbea3f9fd55c1bf9ce1288b5623b3905c3ebd2ff9e60393bab8357a24", "Created": "2020-04-15T15:52:24.875480173Z", "Scope": "local", "Driver": "bridge", "EnableIPv6": false, "IPAM": { "Driver": "default", "Options": null, "Config": [ { "Subnet": "172.
Terminology context: A build’s context is the set of files located in the specified PATH or URL1. Dockerfile sample FROM ubuntu:20.04 ENV TZ=America/Los_Angeles RUN mkdir -p /home/my_user COPY ./files/in_home /home/my_user/in_home ARG DEBIAN_FRONTEND=noninteractive RUN apt update && apt upgrade -y RUN apt install -y nginx php COPY ./files/nginx/my.conf /etc/nginx/sites-available/my.conf RUN ln -s /etc/nginx/sites-available/my.conf /etc/nginx/sites-enabled/my.conf CMD ["nginx", "-g", "daemon off;"] Here is the context.
. ├── Dockerfile └── files ├── in_home(dir) └── nginx └── my.
Definition TF: Term Frequency. IDF: Inverse Document Frequency Document (sentence) -> words.
Terms Capital $D$: A corpus. Subbed (D_i) or lower $d_i$: i-th document in the corpus. TF https://en.wikipedia.org/wiki/Tf–idf
This term is irrelavant to the corpus (defined at each document).
Raw count There are several definitions of “term frequency.”
$$ f_{t,d_i} := \mathrm{the\ number\ of\ the\ words\ }t\ \mathrm{in\ the\ document\ } d_i $$
The most simple and “meaningful” for NLP is frequency form,