jenkin migration할 때 어떤 plugin을 설치했는지 모를 때,

jenkins 홈디렉토리에 plugins 디렉토리를 찾아 설치할 수 있다.


jenkins docker에 plugin 목록으로 사용되니 알아두면 좋다.


JENKINS_HOME이 /var/lib/jenkins/plugins 이거라면 아래와 같이 실행해 플러그인 설치 목록을 확인할 수 있다. 


$ cd  /var/lib/jenkins/plugins


$ ls -al *.jpi  | awk '{print $9}'  | sed 's/.jpi//'

antisamy-markup-formatter

ant

build-timeout

changelog-history

config-file-provider

credentials

external-monitor-job

git-client

github-api

github

github-oauth

git

icon-shim

javadoc

job-restrictions

junit

ldap

locale

mailer

mapdb-api

matrix-auth

matrix-project

naginator

pam-auth

parameterized-trigger

plain-credentials

pyenv

python

ruby-runtime

scm-api

script-security

shiningpanda

ssh-agent

ssh-credentials

ssh-slaves

structs

subversion

token-macro

windows-slaves

workflow-step-api


Posted by '김용환'
,

[python] pickle 예시

python 2018. 9. 12. 14:57



자바의 serialization/deserialization은 언어/jvm 레벨에서 이루어지지만,


파이썬에서는 모듈 단에서 이루어진다. 대표적인 모듈이 pickle이다.


https://docs.python.org/3/library/pickle.html




파이썬에서 list를 바로 파일로 저장할 수 없다. 



>>> mylist = ['a', 'b', 'c', 'd']

>>> with open('test.txt','wb') as f:

...     pickle.dump(mylist,f)

...

>>> with open('test.txt','rb') as f:

...     yourlist=pickle.load(f)

...

>>> yourlist

['a', 'b', 'c', 'd']




주의할 점은 bytes가 아니라 string으로 읽고 저장, 즉 'wb', 'rb'를 해야 한다.


>>> with open('test.txt','w') as f:

...     pickle.dump(mylist,f)

...

Traceback (most recent call last):

  File "<stdin>", line 2, in <module>

TypeError: write() argument must be str, not bytes


'python' 카테고리의 다른 글

파이썬의 try ... import .. except 예시  (0) 2018.10.08
파이썬의 선(Zen of Python)  (0) 2018.09.23
[python] urlsplit 예제  (0) 2018.09.12
파이썬 모듈 프로그래밍 예시 - __init__.py  (0) 2018.09.07
[python] whois 모듈  (0) 2018.09.03
Posted by '김용환'
,

[python] urlsplit 예제

python 2018. 9. 12. 13:12



python에서 URL을 파싱하려면 urllib.parse 모듈의 urlsplit 함수를 사용한다. urlsplit 함수는 URL을 각 구성 요소로 분리한다.




>>> from urllib.parse import urlsplit


>>> components = urlsplit('http://example.webscraping.com/places/default/view')


>>> print(components)

SplitResult(scheme='http', netloc='example.webscraping.com', path='/places/default/view', query='', fragment='')


>>> print(components.path)

/places/default/view





'python' 카테고리의 다른 글

파이썬의 선(Zen of Python)  (0) 2018.09.23
[python] pickle 예시  (0) 2018.09.12
파이썬 모듈 프로그래밍 예시 - __init__.py  (0) 2018.09.07
[python] whois 모듈  (0) 2018.09.03
[python] OptionParser 활용하는 사례  (0) 2018.07.04
Posted by '김용환'
,



쿠버네티스에 배포한후 pods 상태가 이상하다.


$ kubectl apply -f deployment.yaml



$ kubectl get pods

NAME                          READY     STATUS             RESTARTS   AGE

oncall-api-79f79c5bdf-cltxk   0/1       CrashLoopBackOff   7          12m





다시 배포해도 동일한 문제가 발생한다.




문제를 해결할려면 kubectl describe와 kubectl log 커맨드를 사용한다.




$ kubectl describe pods


...

    Port:           5000/TCP

    Host Port:      0/TCP

    State:          Waiting

      Reason:       CrashLoopBackOff

    Last State:     Terminated

      Reason:       Error

      Exit Code:    139

      Started:      Tue, 11 Sep 2018 20:15:41 +0900

      Finished:     Tue, 11 Sep 2018 20:15:41 +0900

    Ready:          False

    Restart Count:  7

    Requests:

      cpu:        500m

      memory:     900Mi

    Environment:  <none>


..

Events:

  Type     Reason                 Age                From                             Message

  ----     ------                 ----               ----                             -------

  Normal   Scheduled              15m                default-scheduler                Successfully assigned ...

  Normal   SuccessfulMountVolume  15m                kubelet, ...

  Normal   Pulled                 13m (x5 over 15m)  kubelet, ....

  Normal   Created                13m (x5 over 15m)  kubelet, ...

  Normal   Started                13m (x5 over 15m)  kubelet, Started container

  Warning  BackOff                7s (x70 over 15m)  kubelet, Back-off restarting failed container


...




kubernetes yaml에 인덴트가 정상인지 확인하고,
잘못된 부분이 어딘가 있을지도 모르니 철자 확인한 후,,
imagePullPolicy 정책이 없다면 always로 수정해야 한다.

http://knight76.tistory.com/entry/kubernetes%EC%97%90%EC%84%9C-%EB%B0%B0%ED%8F%AC-%EC%9D%B4%EB%AF%B8%EC%A7%80-%EC%83%9D%EC%84%B1%EC%8B%9C-%EC%9C%A0%EC%9D%98-%EC%82%AC%ED%95%AD-imagePullPolicy



그래도 안되면 역시 sleep이다. 다음처럼 적당히 자게 한다.  


spec:
containers:
- name: xxxx
image: xxxxx
imagePullPolicy: Always
command: ['sh', '-c', 'echo 'xxx && sleep 6000']


아래와 같은 커맨드를 사용해 포드에 접속해서 문제를 확인한다. 


$ kubectl exec -it --namespace  prod  {포드 이름}  bash 


Posted by '김용환'
,


도커 로컬에서 테스트하는 예제이다.


먼더 Dockerfile이 있는 디렉토리에서 빌드한다


$ docker build . --tag oncall-api:latest



제대로 이미지가 생성되었는지 확인한다


$ docker images

REPOSITORY                                   TAG                 IMAGE ID            CREATED              SIZE

oncall-api                                   latest              e80b7411faea        About a minute ago   94MB



실행한다


$ docker run --name oncall-api -d -p 5000:5000 oncall-api:latest

9198cbd7a9daf801e243393462ee3e9a6a3f046e6e347cf2ab4aea1262ba2d51


$ docker start oncall-api



도커 프로세스로 떠 있는지 확인한다.


$ docker ps -a

CONTAINER ID        IMAGE                                        COMMAND                  CREATED             STATUS                    PORTS                                                      NAMES

9198cbd7a9da        oncall-api:latest                            "gunicorn --workers …"   9 seconds ago       Up 8 seconds              0.0.0.0:5000->5000/tcp                                     oncall-api



Dockerfile에 수정했다면 container를 삭제한다.


$ docker container rm $container_id


빌드(docker build)를 다시하고 재시작한다



$ docker restart oncall-api





Posted by '김용환'
,