-
install kuberntes dashboard
kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v1.10.1/src/deploy/recommended/kubernetes-dashboard.yaml
-
Edit kubernetes service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#https://pybit.es/decorator-optional-argument.html | |
from functools import wraps | |
import time | |
def sleep(seconds=None): | |
def real_decorator(func): | |
@wraps(func) | |
def wrapper(*args, **kwargs): | |
print('Sleeping for {} seconds'.format(seconds)) | |
time.sleep(seconds if seconds else 1) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Echo client program | |
import socket | |
HOST = 'localhost' | |
PORT = 3003 | |
with socket.socket(socket.AF_INET, socket.SOCK_STREAM) as s: | |
s.connect((HOST, PORT)) | |
s.sendall(b'Hello, world') | |
data = s.recv(1024) | |
print('Received', repr(data)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
one = {"XP": 5, "Gold": 5, "Rank": 2, "Diamond":5} | |
two = {"XP": 5, "Gold": 5, "Rank": 2, "Diamond":5} | |
sum_temp = {key:one[key]+two[key] for key in one.keys()} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
data = [{"id":2,"f":3}, | |
{"id":3,'f':4}] | |
a = next(item for item in data if item["id"]==2) | |
print a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import matplotlib.pyplot as plt | |
from sklearn.linear_model import LinearRegression | |
X = np.array( | |
[[0.27090301, 0.4656891496], | |
[0.3080357143, 0.5970809376], | |
[0.3826666667, 0.6700470844], |
docker run -d \
-p 5000:5000 \
--restart=always \
--name registry \
-v "$(pwd)"/auth:/auth \
-e "REGISTRY_AUTH=htpasswd" \
-e "REGISTRY_AUTH_HTPASSWD_REALM=Registry Realm" \
-e REGISTRY_AUTH_HTPASSWD_PATH=/auth/htpasswd \
-e -e REGISTRY_STORAGE_DELETE_ENABLED=true \
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo certbot certonly --standalone -d registry.example.com |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from fastapi import FastAPI | |
from starlette_exporter import PrometheusMiddleware, handle_metrics | |
external = FastAPI() | |
internal = FastAPI() | |
external.add_middleware(PrometheusMiddleware) | |
@external.get("/users/information") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM python:3.8 | |
LABEL maintainer="Sebastian Ramirez <[email protected]>" | |
RUN pip install --no-cache-dir uvicorn gunicorn | |
RUN pip install --no-cache-dir uvloop httptools websockets | |
COPY start.sh /start.sh | |
RUN chmod +x /start.sh | |
COPY gunicorn_conf.py /gunicorn_conf.py |
OlderNewer