$ cat /proc/cpuinfo | grep 'vmx\|svm' flags : fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx rdtscp lm constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc aperfmperf eagerfpu pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm epb tpr_shadow vnmi flexpriority ept vpid fsgsbase smep erms xsaveopt dtherm ida arat pln pts
$ sysctl -a | grep machdep.cpu.features | grep VMX machdep.cpu.features: FPU VME DE PSE TSC MSR PAE MCE CX8 APIC SEP MTRR PGE MCA CMOV PAT PSE36 CLFSH DS ACPI MMX FXSR SSE SSE2 SS HTT TM PBE SSE3 PCLMULQDQ DTES64 MON DSCPL VMX SMX EST TM2 SSSE3 CX16 TPR PDCM SSE4.1 SSE4.2 POPCNT AES PCID
$ dpkg -l | grep virtualbox ii unity-scope-virtualbox 0.1+13.10.20130723-0ubuntu1 all VirtualBox scope for Unity ii virtualbox-5.1 5.1.22-115126~Ubuntu~xenial amd64 Oracle VM VirtualBox
$ ls /Applications | grep VirtualBox VirtualBox.app
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.20.0/minikube-linux-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
$ curl -Lo minikube https://storage.googleapis.com/minikube/releases/v0.20.0/minikube-darwin-amd64 && chmod +x minikube && sudo mv minikube /usr/local/bin/
sudo mv minikube /usr/local/bin/
can be removed or changed if you want to use a different path. $ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/linux/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
$ sudo snap install kubectl --classic
$ curl -LO https://storage.googleapis.com/kubernetes-release/release/$(curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt)/bin/darwin/amd64/kubectl && chmod +x kubectl && sudo mv kubectl /usr/local/bin/
$ minikube start Starting local Kubernetes v1.6.4 cluster... Starting VM... Moving files into cluster... Setting up certs... Starting cluster components... Connecting to cluster... Setting up kubeconfig... Kubectl is now configured to use the cluster.
$ kubectl get pods --all-namespaces NAMESPACE NAME READY STATUS RESTARTS AGE kube-system kube-addon-manager-minikube 1/1 Running 6 1d kube-system kube-dns-1301475494-p5x6k 3/3 Running 18 1d kube-system kubernetes-dashboard-llc98 1/1 Running 6 1d
$ kubectl get nodes NAME STATUS AGE VERSION minikube Ready 1d v1.6.4
hello-minikube
. Since we have already started the cluster, we can skip the first step ( minikube start
).hello-minikube
. To do this, a pre-configured deployment will be created: $ kubectl run hello-minikube --image=gcr.io/google_containers/echoserver:1.4 --port=8080 deployment "hello-minikube" created
$ kubectl get pods NAME READY STATUS RESTARTS AGE hello-minikube-938614450-nng53 1/1 Running 0 2m $ kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE hello-minikube 1 1 1 1 2m
hello-minikube
you need to open an external IP with the command: $ kubectl expose deployment hello-minikube --type=NodePort service "hello-minikube" exposed
NodePort
type, since Minikube does not support the LoadBalancer
service. So you can make sure that the service is open: $ kubectl get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-minikube 10.0.0.70 <nodes> 8080:30531/TCP 2m kubernetes 10.0.0.1 <none> 443/TCP 1d
curl
from the command line, or the browser to open a link to the service. To find out its external IP and port, first use the command: $ minikube service hello-minikube --url http://192.168.99.100:30531 $ curl $(minikube service hello-minikube --url) CLIENT VALUES: client_address=172.17.0.1 command=GET real path=/ query=nil request_version=1.1 request_uri=http://192.168.99.100:8080/ SERVER VALUES: server_version=nginx: 1.10.0 - lua: 10001 HEADERS RECEIVED: accept=*/* host=192.168.99.100:30531 user-agent=curl/7.47.0 BODY: -no body in request-
minikube ip
command or in the output of ifconfig
: β¦ vboxnet0 Link encap:Ethernet HWaddr 0a:00:27:00:00:00 inet addr:192.168.99.1 Bcast:192.168.99.255 Mask:255.255.255.0 β¦
hello-minikube
, we can delete its deployment and service, freeing up resources and checking that everything is really deleted: $ kubectl delete service,deployment hello-minikube service "hello-minikube" deleted deployment "hello-minikube" deleted $ kubectl get pods No resources found. $ kubectl get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE kubernetes 10.0.0.1 <none> 443/TCP 1d
hello-node
: $ mkdir hello-node && cd hello-node && touch Dockerfile server.js $ tree . βββ Dockerfile βββ server.js 0 directories, 2 files
$ vi server.js var http = require('http'); var handleRequest = function(request, response) { response.writeHead(200); response.end('Hello World!'); }; var helloServer = http.createServer(handleRequest); helloServer.listen(8080);
Dockerfile
by declaring that the image uses node 4.4 and the container starts the service using the server.js
file: $ vi Dockerfile FROM node:4.4 EXPOSE 8080 COPY server.js . CMD node server.js
eval $(docker-machine env)
, we create Docker environment variables for Minikube using the minikube docker-env
: $ eval $(minikube docker-env)
.
At the end of the command, Docker says to collect the image from the current directory - approx. Transl. ) : $ docker build -t hello-node:v1 . Sending build context to Docker daemon 3.072kB Step 1 : FROM node:4.4 ---> 93b396996a16 Step 2 : EXPOSE 8080 ---> Using cache ---> 989ed85905c2 Step 3 : COPY server.js . ---> a5dc90f3df9d Removing intermediate container 8fbc055e7016 Step 4 : CMD node server.js ---> Running in c58bc5e3daff ---> 8521ce4accb3 Removing intermediate container c58bc5e3daff Successfully built 8521ce4accb3 $ docker images REPOSITORY TAG IMAGE ID CREATED SIZE hello-node v1 8521ce4accb3 30 seconds ago 647MB <none> <none> dc5a4cc0b371 3 days ago 647MB gcr.io/google_containers/kubernetes-dashboard-amd64 v1.6.1 71dfe833ce74 2 months ago 134MB gcr.io/google_containers/k8s-dns-sidecar-amd64 1.14.2 7c4034e4ffa4 2 months ago 44.5MB gcr.io/google_containers/k8s-dns-kube-dns-amd64 1.14.2 ca8759c215c9 2 months ago 52.4MB gcr.io/google_containers/k8s-dns-dnsmasq-nanny-amd64 1.14.2 e5c335701995 2 months ago 44.8MB gcr.io/google-containers/kube-addon-manager v6.4-beta.1 85809f318123 4 months ago 127MB node 4.4 93b396996a16 11 months ago 647MB gcr.io/google_containers/echoserver 1.4 a90209bb39e3 13 months ago 140MB gcr.io/google_containers/pause-amd64 3.0 99e59f495ffa 14 months ago 747kB
hello-node
in the local cluster Kubernetes using kubectl
: $ kubectl run hello-node --image=hello-node:v1 --port=8080 deployment "hello-node" created $ kubectl get pods NAME READY STATUS RESTARTS AGE hello-node-1644695913-h7qwh 1/1 Running 0 6s $ kubectl get deployments NAME DESIRED CURRENT UP-TO-DATE AVAILABLE AGE hello-node 1 1 1 1 18s
curl
: $ kubectl expose deployment hello-node --type=NodePort service "hello-node" exposed $ kubectl get services NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE hello-node 10.0.0.219 <nodes> 8080:30987/TCP 8s kubernetes 10.0.0.1 <none> 443/TCP 4d $ curl $(minikube service hello-node --url) Hello World!
hello-node
and turn off the minikube
service when done: $ kubectl delete service,deployment hello-node service "hello-node" deleted deployment "hello-node" deleted $ minikube stop Stopping local Kubernetes cluster... Machine stopped.
Source: https://habr.com/ru/post/333470/
All Articles