(쿠버네티스를 처음 공부하고 테스트하는 사람에게 도움이 된다)


간단하게 kubernetes 앱을 실행할 때는 apply를 사용하는 것이 가장 쉽다. 


kubectl apply -f kubernetes.yml



반대로 자원/실행 종료는 다음과 같다.


kubectl delete -f kubernetes.yml


기억이 나지 않을 때는 아래와 같이 delete를 직접 해도 된다.


kubectl delete deployment {deployment_name} 



kubectl delete 를 진행할 때 주의해야 하는 부분이 있다. 





만약 namespace를 정하면 부분이 yaml에 있는데 kubectl delete를 실행하면 namespace의 모든 deployment도 삭제되니. 주의해야 한다.


Posted by '김용환'
,


애플리케이션을 하나만 사용할 때는 대충 아래와 같이 사용할 수 있으나. 


$ kubectl get pod,service,deployment  -n production



엄청나게 많은 애플리케이션이 실행 중이라면 잘 눈에 들어오지 않는다.


service/selector를 이용해 상태를 확인할 수 있다. 



$ kubectl get pod,service,deployment --selector app=in-config -n production

NAME                            READY   STATUS    RESTARTS   AGE

pod/in-config-b6c89f44b-2mpr8   1/1     Running   0          32m

pod/in-config-b6c89f44b-fd58c   1/1     Running   0          44m

....


Posted by '김용환'
,



커맨드 기록 저장하기. 


$ kubectl apply -f kubernetes.yml  --record



커맨드 히스토리 보기

$ kubectl rollout history deployment in-config -n production

deployment.extensions/google-config

REVISION  CHANGE-CAUSE

1         kubectl apply --filename=kubernetes.yml --record=true




history의 revision 1으로 롤백도 할 수 있다. 


$ kubectl rollout history deployment in-config -n production --revision=1

deployment.extensions/in-config with revision #1

Pod Template:

  Labels: app=google-config

pod-template-hash=627459006

  Annotations: kubernetes.io/change-cause: kubectl apply --filename=kubernetes.yml --record=true

  Containers:

   google-config:

    Image: ..

    Port: 8080/TCP

    Host Port: 0/TCP

    Requests:

      cpu: 1

      memory: 1000Mi

    Liveness: http-get http://:8080/actuator/health delay=3s timeout=1s period=3s #success=1 #failure=3

    Environment: <none>

    Mounts: <none>

  Volumes: <none>



비슷하게 바로 직전으로 롤백할 수 있다.


$ kubectl rollout undo deployment  in-config -n production


Posted by '김용환'
,


spring cloud config를 살펴보니..  4가지 정도가 주의하면 좋을 것 같다.


1. 
Spring Cloud(Boot) 주요 클래스에 @EnableConfigServer를 붙이기


@RestController
@EnableConfigServer
@SpringBootApplication
public class ConfigServerApplication {

@RequestMapping(value = "/")
public @ResponseBody String root() {
return "Global Config Server";
}

public static void main(String[] args) {
SpringApplication.run(ConfigServerApplication.class, args);
}
}



2. 

설정 이름 주의하기

yaml 파일의 이름을

${ApplicationName}-${EnvironmentName}.yml로 설정해야 한다.


즉 아래와 같은 형태로 되어야 spring cloud config 설정을 확인할 수 있다. 

global-beta.yml

order-alpha.yml


따라서


http://localhot:8080/global/beta 

http://localhot:8080/order/alpha 이렇게 접근할 수 있다.




3. 

private 저장소의 경우 암호를 넣어야 한다.

spring.cloud.config.server.git.username=google-lab
spring.cloud.config.server.git.password=lab1234



4. 

spring cloud git url을 설정할 때 root 주소로 접근해야지 git 저장소의 sub directory에 접근하려고 하면 파싱 에러(org.eclipse.jgit.api.errors.TransportException: invalid advertisement of) 가 난다. 


이렇게 하지 말고

spring.cloud.config.server.git.uri=https://github.com/google/internal-config/config


아래와 같이 저장소 로 접근해야 한다.

spring.cloud.config.server.git.uri=https://github.com/google/internal-config


runtime 에러에서 final int tab = line.indexOf('\t'); 부분에서 에러가 발생한 것을 확인할 수 있다.

package org.eclipse.jgit.transport;

public class TransportHttp extends HttpTransport implements WalkTransport,

PackTransport {


Map<String, Ref> readAdvertisedImpl(final BufferedReader br)

throws IOException, PackProtocolException {

final TreeMap<String, Ref> avail = new TreeMap<>();

for (;;) {

String line = br.readLine();

if (line == null)

break;


final int tab = line.indexOf('\t');

if (tab < 0)

throw invalidAdvertisement(line);




git 저장소 대신 로컬 파일 시스템에서 테스트하려면 spring.cloud.config.enabled=false을 사용한다. 




Posted by '김용환'
,

[sbt] 1.3.0

scala 2019. 9. 6. 10:22



https://github.com/sbt/sbt/releases/tag/v1.3.0


sbt 1.3.0에 병렬 라이브러리 다운로드 cousier를 포함하게 되었다.

super shell도 있고..

Posted by '김용환'
,