Get the public IP addresses of nodes in a Kubernetes cluster:
kubectl get nodes -o wide
Get the public IP address, in an unnecessarily round-about way, of the node that a particular service is running on:
# Create an nginx deployment and service
| import requests | |
| import pandas as pd | |
| from bs4 import BeautifulSoup | |
| # Fetching S&P 500 tickers and company names from Wikipedia | |
| url = 'https://en.wikipedia.org/wiki/List_of_S%26P_500_companies' | |
| response = requests.get(url) | |
| soup = BeautifulSoup(response.text, 'html.parser') | |
| table = soup.find('table', {'class': 'wikitable sortable'}) |
| import matplotlib.pyplot as plt | |
| import numpy as np | |
| # https://jakevdp.github.io/PythonDataScienceHandbook/04.12-three-dimensional-plotting.html | |
| def f(x, y): | |
| return np.sin(np.sqrt(x ** 2 + y ** 2)) | |
| x = np.linspace(-6, 6, 30) | |
| y = np.linspace(-6, 6, 30) |
| import pandas as pd | |
| import pulp as P | |
| # Define Constraints, Solve, Print Status, Variables, Objective | |
| model = P.LpProblem("Maximize Bakery Profits", P.LpMaximize) | |
| R = P.LpVariable('Regular_production', lowBound=0, cat='Continuous') | |
| J = P.LpVariable('Jumbo_production', lowBound=0, cat='Continuous') | |
| model += 5 * R + 10 * J, "Profit" | |
| # Adjust the constraint |
| import cvxpy as cp | |
| import numpy as np | |
| # Problem data | |
| m = 30 | |
| n = 20 | |
| np.random.seed(1) | |
| A = np.random.randn(m, n) | |
| b = np.random.randn(m) |
| FROM nginx:latest | |
| COPY src /usr/share/nginx/html | |
| # docker build -t try-docker-nginx-statichtml . | |
| # docker run -p 8080:80 try-docker-nginx-statichtml | |
| # open localhost:8080 in browser |
| <!doctype html> | |
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="width=device-width, initial-scale=1"> | |
| </head> | |
| <body> |
| import simpy | |
| import random | |
| import statistics | |
| env = simpy.Environment() | |
| charger = simpy.Resource(env, 5) | |
| class Lazer(object): |
Get the public IP addresses of nodes in a Kubernetes cluster:
kubectl get nodes -o wide
Get the public IP address, in an unnecessarily round-about way, of the node that a particular service is running on:
# Create an nginx deployment and service
Let's assume you have a running docker container with a webserver that serves requests. You want to see
the requests and responses it receives. You can use the --net container:<id> of the docker run command.
First, you have to discover the ID of the container that you want to monitor. Use docker ps to get it.
# On host
docker ps