Udacity | SUSE: 아키텍처 고려사항 - 랩
This is the fourth article in the series, Udacity: SUSE Cloud Native Foundations. This is an extension of the previous article, .
이 섹션에서는 이전 섹션의 두 가지 연습과 한 가지 edge 사례를 살펴보겠습니다.
연습 1: 응용 프로그램 상태의 끝점
클론 랩 저장소는 여기link에 있습니다.
$ git clone https://github.com/udacity/nd064_course_1.git
$ ls -ltr
drwxr-xr-x 1 Eden Jose 197610    0 Jun 18 19:41 nd064_course_1/ 
exercises/python-helloworld 폴더로 이동합니다.$ cd nd064_course_1/
$ ls -l
total 25
drwxr-xr-x 1 Eden Jose 197610  0 Jun 18 19:41 exercises/
drwxr-xr-x 1 Eden Jose 197610  0 Jun 18 19:41 project/
-rw-r--r-- 1 Eden Jose 197610 12 Jun 18 19:41 README.md
drwxr-xr-x 1 Eden Jose 197610  0 Jun 18 19:41 solutions/
$ cd exercises/python-helloworld/
$ ls -l
total 6
-rw-r--r-- 1 Eden Jose 197610 167 Jun 18 19:41 app.py
-rw-r--r-- 1 Eden Jose 197610  32 Jun 18 19:41 requirements.txt
nd064_course_1를 프로젝트 폴더로 사용하고 가상 환경을 만들어flask를 설치할 수 있습니다.가상 환경을 만들려면 다음 명령을 실행합니다.$ cd nd064_course_1
$ python -m venv env
env 에서 새 nd064_course_1 폴더를 볼 수 있을 것입니다.$ ls -l
total 13
drwxr-xr-x 1 Eden Jose 197610  0 Jun 18 21:27 env/
drwxr-xr-x 1 Eden Jose 197610  0 Jun 18 21:12 exercises/
drwxr-xr-x 1 Eden Jose 197610  0 Jun 18 19:41 project/
-rw-r--r-- 1 Eden Jose 197610 12 Jun 18 19:41 README.md
drwxr-xr-x 1 Eden Jose 197610  0 Jun 18 19:41 solutions/
nd064_course_1 폴더를 열고 명령 팔레트(보기 > 명령 팔레트 또는 (Ctrl+Shift+P)를 엽니다.그리고 Python:select 해석기 명령을 선택한 다음 프로젝트 폴더에서 ./env 또는 .\env로 시작하는 가상 환경을 선택하십시오. 
  
 가상 환경을 활성화하기 위해 새 터미널을 엽니다.
가상 환경에 flask를 설치합니다.
$ python -m pip install flask
exercises/ython-helloworld 폴더로 이동하여 다음 명령을 실행합니다.이 명령은 Flask 개발 서버를 실행하고 응용 프로그램을 찾습니다.기본값은 py입니다.$ cd exercises/python-helloworld/
$ python -m flask run
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
127.0.0.1:5000로 이동합니다. 
 다음 요구 사항을 고려하여 Python Flask 응용 프로그램을
/status 및 /metrics 엔드포인트로 확장합니다.(참고: JSON 응답은 이 단계에서 하드코딩 가능)
편집
app.py:from flask import Flask
from flask import json
app = Flask(__name__)
@app.route('/status')
def status():
response = app.response_class(
        response=json.dumps({"result":"OK - healthy"}),
        status=200,
        mimetype='application/json'
)
return response
@app.route('/metrics')
def metrics():
response = app.response_class(
        response=json.dumps({"status":"success","code":0,"data":{"UserCount":140,"UserCountActive":23}}),
        status=200,
        mimetype='application/json'
)
return response
@app.route("/")
def hello():
return "Hello World!"
if __name__ == "__main__":
app.run(host='0.0.0.0')
app.py 을 실행하고 브라우저에서 다시 링크 127.0.0.1:5000 를 열려고 시도합니다.$ python -m flask run
* Environment: production
WARNING: This is a development server. Do not use it in a production deployment.
Use a production WSGI server instead.
* Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
 
 추가
/status 및 /metrics를 통해 종단점이 제대로 작동하는지 확인 
 연습 2: 애플리케이션 로그
이 단계에서 Hello World 프로그램을 확장해서 서로 다른 단점을 처리합니다.일단 종점에 도착하면 이 조작을 표시하는 기록선을 기록해야 한다.
이 연습에서는 Hello World 응용 프로그램 collect logs를 개발하고 다음 요구 사항을 충족해야 합니다.
"{{TIMESTAMP}}, {{ ENDPOINT_NAME}} endpoint was reached"
수정
app.py.여기서 우리가 사용하는 것은 app.logger 단점에 따라 정보를 기록하는 것이다.로그를 특정 파일에 저장하기 위해서, 우리는 파이톤의 logging module 을 사용합니다.이 로그들은 현재 app.log라는 파일로 유동적으로 전송됩니다.
from flask import Flask
from flask import json
import logging
app = Flask(__name__)
@app.route('/status')
def healthcheck():
    response = app.response_class(
            response=json.dumps({"result":"OK - healthy"}),
            status=200,
            mimetype='application/json'
    )
    ## log line
    app.logger.info('Status request successfull')
    return response
@app.route('/metrics')
def metrics():
    response = app.response_class(
            response=json.dumps({"status":"success","code":0,"data":{"UserCount":140,"UserCountActive":23}}),
            status=200,
            mimetype='application/json'
    )
    ## log line
    app.logger.info('Metrics request successfull')
    return response
@app.route("/")
def hello():
    ## log line
    app.logger.info('Main request successfull')
    return "Hello World!"
if __name__ == "__main__":
    ## stream logs to app.log file
    logging.basicConfig(filename='app.log',level=logging.DEBUG)
    app.run(host='0.0.0.0')
$ python app.py 
 * Serving Flask app 'app' (lazy loading)
 * Environment: production
   WARNING: This is a development server. Do not use it in a production deployment.
   Use a production WSGI server instead.
 * Debug mode: off
 * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
 * Running on http://192.168.254.105:5000/ (Press CTRL+C to quit)
 
    
    
  터미널로 돌아가면
app.log 폴더에 exercises/python-helloworld 가 만들어진 것을 볼 수 있습니다.$ ls -l
total 10
drwxr-xr-x 1 Eden Jose 197610   0 Jun 18 22:22 __pycache__/
-rw-r--r-- 1 Eden Jose 197610 685 Jun 18 22:54 app.log
-rw-r--r-- 1 Eden Jose 197610 998 Jun 18 22:52 app.py
-rw-r--r-- 1 Eden Jose 197610  32 Jun 18 19:41 requirements.txt
$ cat app.log
WARNING:werkzeug: * Running on all addresses.
   WARNING: This is a development server. Do not use it in a production deployment.
INFO:werkzeug: * Running on http://192.168.254.105:5000/ (Press CTRL+C to quit)
INFO:app:Main request successfull
INFO:werkzeug:127.0.0.1 - - [18/Jun/2021 22:53:51] "GET / HTTP/1.1" 200 -
INFO:app:Main request successfull
INFO:werkzeug:127.0.0.1 - - [18/Jun/2021 22:54:11] "GET / HTTP/1.1" 200 -
INFO:app:Metrics request successfull
INFO:werkzeug:192.168.254.105 - - [18/Jun/2021 22:54:21] "GET /metrics HTTP/1.1" 200 -
INFO:app:Metrics request successfull
INFO:werkzeug:192.168.254.105 - - [18/Jun/2021 22:54:24] "GET /metrics HTTP/1.1" 200 -
테두리 사례: 비결정 응용
한 엔지니어링 팀이 하나의 제품(monolith와 Micro 서비스 포함)을 성공적으로 발표한 후에 응용 프로그램의 생명 주기의 다음 단계는 유지보수이다.본 예에서 우리는 제품 발표 후 자주 사용하는 유지보수 조작을 탐구할 것이다.
 
 전체 유지보수 단계에서 응용 프로그램의 구조와 기능에 변화가 발생할 수 있다는 것은 예상한 것이다!응용 프로그램의 체계 구조는 정태적이지 않고 무정형이며 끊임없이 이동 중이다.이것은 제품의 유기적인 성장을 대표하는데 이 제품은 고객의 피드백과 신흥 기술에 호응할 수 있다.
제품 발표 후 유지보수 단계에서monolith와 마이크로 서비스를 바탕으로 하는 응용 프로그램은 모두 과도할 것이다.새로운 기능을 추가하거나 도구를 통합하는 것을 고려할 때 유연성이 아니라 확장성에 관심을 가져야 한다.
 
 일반적으로 정의가 양호하고 간단한 기능을 사용하여 여러 서비스(예를 들어 마이크로 서비스)를 관리하는 것이 새로운 서비스(예를 들어 우리가 Monolith에서 본 것)를 지원하는 것보다 더 효과적이다.그러나 구조가 좋은 유지보수 단계를 가지려면 응용 프로그램의 구조를 선택하는 원인과 관련된 균형을 알아야 한다.
유지 관리 단계에서 가장 일반적인 몇 가지 작업은 다음과 같습니다.
 
 와, 그건 장편대론이야!걱정하지 마십시오. 다음 절에서는 Kubernetes의 용기를 사용해서 배열하는 것을 중점적으로 토론할 것입니다.
안녕히 계세요!😁
If you enjoy this write-up and would like to learn more, make sure to hit the Follow just below and bookmark the series. I'll also be glad to connect with you on .
See you there! 😃
.ltag__user__id__350730.작업 따르기 버튼
배경색: #7eb4fb!중요
색상: #fcef98!중요
테두리 색상: #7eb4fb!중요
}
 
      이든 호세 포레
A cloud enthusiast, an IT Professional, and a problem-solver. I am either learning something new, running a mile, or planning my next 100 days.
Reference
이 문제에 관하여(Udacity | SUSE: 아키텍처 고려사항 - 랩), 우리는 이곳에서 더 많은 자료를 발견하고 링크를 클릭하여 보았다 https://dev.to/jeden/udacity-suse-architecture-considerations-lab-305g텍스트를 자유롭게 공유하거나 복사할 수 있습니다.하지만 이 문서의 URL은 참조 URL로 남겨 두십시오.
                                
                                
                                
                                
                                
                                우수한 개발자 콘텐츠 발견에 전념
                                (Collection and Share based on the CC Protocol.)