03 Mar 2018
|
OpenShift
Dockerfile
Go 프로젝트 배포
Docker Image를 이용해서 배포하는 경우와 Git 소스 코드를 이용해서 배포하는 yaml 코드 예제입니다.
사용방법은 예시는 다음과 같습니다.
$ oc create -f deployment-using-docker-image.yaml
$ oc create -f deployment-using-git.yaml
전체 코드는 GitHub에서 확인할 수 있습니다.
Dockerfile
FROM golang:1.9.1-alpine3.6
WORKDIR /go/src/app
COPY ./app .
RUN go get -d -v ./...
RUN go install -v ./...
EXPOSE 8080
EXPOSE 8888
CMD ["/go/bin/app"]
deployment-using-docker-image.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: go-sample
labels:
app: go-sample
spec:
template:
metadata:
labels:
app: go-sample
spec:
containers:
- image: snowdeer/go-sample:latest
name: go-sample
ports:
- containerPort: 8080
protocol: TCP
- containerPort: 8888
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: go-sample
labels:
app: go-sample
spec:
ports:
- name: go-sample-port1
port: 8080
protocol: TCP
targetPort: 8080
- name: go-sample-port2
port: 8888
protocol: TCP
targetPort: 8888
selector:
app: go-sample
type: LoadBalancer
---
apiVersion: v1
kind: Route
metadata:
name: go-sample
labels:
app: go-sample
spec:
port:
targetPort: go-sample-port1
to:
kind: Service
name: go-sample
weight: 100
deployment-using-git.yaml
apiVersion: v1
kind: BuildConfig
metadata:
labels:
app: go-sample
name: go-sample
spec:
failedBuildsHistoryLimit: 3
nodeSelector: null
postCommit: {}
resources: {}
runPolicy: Serial
source:
git:
uri: 'https://github.com/snowdeer/openshift-go-sample.git'
type: Git
strategy:
dockerStrategy:
from:
kind: DockerImage
name: 'ubuntu:latest'
type: Docker
successfulBuildsHistoryLimit: 5
output:
to:
kind: ImageStreamTag
name: 'go-sample:latest'
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: go-sample
labels:
app: go-sample
spec:
template:
metadata:
labels:
app: go-sample
spec:
containers:
- image: snowdeer/go-sample:latest
name: go-sample
ports:
- containerPort: 8080
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: go-sample
labels:
app: go-sample
spec:
ports:
- name: go-sample-port1
port: 8080
protocol: TCP
targetPort: 8080
- name: go-sample-port2
port: 8888
protocol: TCP
targetPort: 8888
selector:
app: go-sample
type: LoadBalancer
---
apiVersion: v1
kind: Route
metadata:
name: go-sample
labels:
app: go-sample
spec:
port:
targetPort: go-sample-port1
to:
kind: Service
name: go-sample
weight: 100
02 Mar 2018
|
OpenShift
Dockerfile
Python 프로젝트 배포
Docker Image를 이용해서 배포하는 경우와 Git 소스 코드를 이용해서 배포하는 yaml 코드 예제입니다.
사용방법은 예시는 다음과 같습니다.
$ oc create -f deployment-using-docker-image.yaml
$ oc create -f deployment-using-git.yaml
전체 코드는 GitHub에서 확인할 수 있습니다.
Dockerfile
FROM ubuntu
# basic setting for python
RUN apt-get update
RUN apt-get install -y python python-pip
# install my app
WORKDIR /app
COPY . .
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
# expose ports
EXPOSE 8080
## launch
CMD [ "python", "./app/server.py" ]
deployment-using-docker-image.yaml
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: python-sample
labels:
app: python-sample
spec:
template:
metadata:
labels:
app: python-sample
spec:
containers:
- image: snowdeer/python-sample:latest
name: python-sample
ports:
- containerPort: 8080
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: python-sample
labels:
app: python-sample
spec:
ports:
- name: python-sample
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: python-sample
type: LoadBalancer
---
apiVersion: v1
kind: Route
metadata:
name: python-sample
labels:
app: python-sample
spec:
port:
targetPort: python-sample
to:
kind: Service
name: python-sample
weight: 100
deployment-using-git.yaml
apiVersion: v1
kind: BuildConfig
metadata:
labels:
app: python-sample
name: python-sample
spec:
failedBuildsHistoryLimit: 3
nodeSelector: null
postCommit: {}
resources: {}
runPolicy: Serial
source:
git:
uri: 'https://github.com/snowdeer/openshift-python-sample.git'
type: Git
strategy:
dockerStrategy:
from:
kind: DockerImage
name: 'ubuntu:latest'
type: Docker
successfulBuildsHistoryLimit: 5
output:
to:
kind: ImageStreamTag
name: 'python-sample:latest'
---
apiVersion: extensions/v1beta1
kind: Deployment
metadata:
name: python-sample
labels:
app: python-sample
spec:
template:
metadata:
labels:
app: python-sample
spec:
containers:
- image: snowdeer/python-sample:latest
name: python-sample
ports:
- containerPort: 8080
protocol: TCP
---
apiVersion: v1
kind: Service
metadata:
name: python-sample
labels:
app: python-sample
spec:
ports:
- name: python-sample
port: 8080
protocol: TCP
targetPort: 8080
selector:
app: python-sample
type: LoadBalancer
---
apiVersion: v1
kind: Route
metadata:
name: python-sample
labels:
app: python-sample
spec:
port:
targetPort: python-sample
to:
kind: Service
name: python-sample
weight: 100
02 Mar 2018
|
Node.js
Hello Node.js
package.json
{
"name": "hello",
"version": "1.0.0",
"description": "",
"main": "app.js",
"scripts": {
"test": "echo \"Error: no test specified\"exit 1",
"start": "node app.js"
},
"author": "",
"license": "Apache",
"dependencies": {
"express": "^4.16.2"
}
}
app.js
var port = 8080;
var express = require('express');
var app = express();
app.get('/', function (req, res) {
res.send('This is an index page.');
});
app.get('/hello', function (req, res) {
res.send('Hello World!');
});
app.listen(port, function () {
console.log('Example app is listening on port ', port);
});
02 Mar 2018
|
리눅스
Ubuntu 18.04에 Libre Office 수동으로 설치하는 방법
sudo add-apt-repository ppa:libreoffice/ppa
sudo apt-get update
sudo apt-get install libreoffice
삭제 방법
sudo apt-get remove libreoffice-core
sudo apt-get remove --purge libreoffice-core
01 Mar 2018
|
OpenShift
OpenShift Cluster UP/DOWN
AWS가 아닌 다른 서버에서 OpenShift의 클러스터(Cluster)를 UP/DOWN 시킬 때는 단순히
$ oc cluster up
$ oc cluster down
명령어만 사용하면 됩니다.
AWS에서 클러스터 UP을 하기 위해서는 다음 스크립트를 실행하면 됩니다.
metadata_endpoint="http://169.254.169.254/latest/meta-data"
public_hostname="$( curl "${metadata_endpoint}/public-hostname" )"
public_ip="$( curl "${metadata_endpoint}/public-ipv4" )"
oc cluster up --public-hostname="${public_hostname}" --routing-suffix="${public_ip}.nip.io"
클러스터 Down 명령어는 동일합니다.