Support
Quality
Security
License
Reuse
kandi has reviewed metrics and discovered the below as its top functions. This is intended to give you an instant insight into metrics implemented functionality, and help decide if they suit your requirements.
:chart_with_upwards_trend: Capturing JVM- and application-level metrics. So you know what's going on.
Microk8s dashboard using nginx-ingress via http not working (Error: `no matches for kind "Ingress" in version "extensions/v1beta1"`)
error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minimal-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /testpath
pathType: Prefix
backend:
service:
name: test
port:
number: 80
-----------------------
error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minimal-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /testpath
pathType: Prefix
backend:
service:
name: test
port:
number: 80
-----------------------
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /$2
nginx.ingress.kubernetes.io/configuration-snippet: |
rewrite ^(/dashboard)$ $1/ redirect;
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
kubernetes.io/ingress.class: public
name: dashboard
namespace: kube-system
spec:
rules:
- http:
paths:
- path: /dashboard(/|$)(.*)
pathType: Prefix
backend:
service:
name: kubernetes-dashboard
port:
number: 443
How to prevent Keras from computing metrics during training
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
def metric_graph(in1, in2, out):
actual_metric = out * (in1 + in2)
return K.switch(K.learning_phase(), tf.zeros((1,)), actual_metric)
x1 = numpy.ones((5,3))
x2 = numpy.ones((5,3))
y = 3*numpy.ones((5,1))
vx1 = numpy.ones((5,3))
vx2 = numpy.ones((5,3))
vy = 3*numpy.ones((5,1))
def metric_eager(in1, in2, out):
if (K.learning_phase()):
return 0
else:
return out * (in1 + in2)
def metric_graph(in1, in2, out):
actual_metric = out * (in1 + in2)
return K.switch(K.learning_phase(), tf.zeros((1,)), actual_metric)
ins1 = Input((3,))
ins2 = Input((3,))
outs = Concatenate()([ins1, ins2])
outs = Dense(1)(outs)
model = Model([ins1, ins2],outs)
model.add_metric(metric_graph(ins1, ins2, outs), name='my_metric', aggregation='mean')
model.compile(loss='mse', optimizer='adam')
model.fit([x1, x2],y, validation_data=([vx1, vx2], vy), epochs=3)
-----------------------
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
def metric_graph(in1, in2, out):
actual_metric = out * (in1 + in2)
return K.switch(K.learning_phase(), tf.zeros((1,)), actual_metric)
x1 = numpy.ones((5,3))
x2 = numpy.ones((5,3))
y = 3*numpy.ones((5,1))
vx1 = numpy.ones((5,3))
vx2 = numpy.ones((5,3))
vy = 3*numpy.ones((5,1))
def metric_eager(in1, in2, out):
if (K.learning_phase()):
return 0
else:
return out * (in1 + in2)
def metric_graph(in1, in2, out):
actual_metric = out * (in1 + in2)
return K.switch(K.learning_phase(), tf.zeros((1,)), actual_metric)
ins1 = Input((3,))
ins2 = Input((3,))
outs = Concatenate()([ins1, ins2])
outs = Dense(1)(outs)
model = Model([ins1, ins2],outs)
model.add_metric(metric_graph(ins1, ins2, outs), name='my_metric', aggregation='mean')
model.compile(loss='mse', optimizer='adam')
model.fit([x1, x2],y, validation_data=([vx1, vx2], vy), epochs=3)
-----------------------
import tensorflow as tf
tf.compat.v1.disable_eager_execution()
def metric_graph(in1, in2, out):
actual_metric = out * (in1 + in2)
return K.switch(K.learning_phase(), tf.zeros((1,)), actual_metric)
x1 = numpy.ones((5,3))
x2 = numpy.ones((5,3))
y = 3*numpy.ones((5,1))
vx1 = numpy.ones((5,3))
vx2 = numpy.ones((5,3))
vy = 3*numpy.ones((5,1))
def metric_eager(in1, in2, out):
if (K.learning_phase()):
return 0
else:
return out * (in1 + in2)
def metric_graph(in1, in2, out):
actual_metric = out * (in1 + in2)
return K.switch(K.learning_phase(), tf.zeros((1,)), actual_metric)
ins1 = Input((3,))
ins2 = Input((3,))
outs = Concatenate()([ins1, ins2])
outs = Dense(1)(outs)
model = Model([ins1, ins2],outs)
model.add_metric(metric_graph(ins1, ins2, outs), name='my_metric', aggregation='mean')
model.compile(loss='mse', optimizer='adam')
model.fit([x1, x2],y, validation_data=([vx1, vx2], vy), epochs=3)
-----------------------
class MyCustomMetricCallback(tf.keras.callbacks.Callback):
def __init__(self, train=None, validation=None):
super(MyCustomMetricCallback, self).__init__()
self.train = train
self.validation = validation
def on_epoch_end(self, epoch, logs={}):
mse = tf.keras.losses.mean_squared_error
if self.train:
logs['my_metric_train'] = float('inf')
X_train, y_train = self.train[0], self.train[1]
y_pred = self.model.predict(X_train)
score = mse(y_train, y_pred)
logs['my_metric_train'] = np.round(score, 5)
if self.validation:
logs['my_metric_val'] = float('inf')
X_valid, y_valid = self.validation[0], self.validation[1]
y_pred = self.model.predict(X_valid)
val_score = mse(y_pred, y_valid)
logs['my_metric_val'] = np.round(val_score, 5)
def build_model():
inp1 = Input((5,))
inp2 = Input((5,))
out = Concatenate()([inp1, inp2])
out = Dense(1)(out)
model = Model([inp1, inp2], out)
model.compile(loss='mse', optimizer='adam')
return model
X_train1 = np.random.uniform(0,1, (100,5))
X_train2 = np.random.uniform(0,1, (100,5))
y_train = np.random.uniform(0,1, (100,1))
X_val1 = np.random.uniform(0,1, (100,5))
X_val2 = np.random.uniform(0,1, (100,5))
y_val = np.random.uniform(0,1, (100,1))
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train), validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train))])
-----------------------
class MyCustomMetricCallback(tf.keras.callbacks.Callback):
def __init__(self, train=None, validation=None):
super(MyCustomMetricCallback, self).__init__()
self.train = train
self.validation = validation
def on_epoch_end(self, epoch, logs={}):
mse = tf.keras.losses.mean_squared_error
if self.train:
logs['my_metric_train'] = float('inf')
X_train, y_train = self.train[0], self.train[1]
y_pred = self.model.predict(X_train)
score = mse(y_train, y_pred)
logs['my_metric_train'] = np.round(score, 5)
if self.validation:
logs['my_metric_val'] = float('inf')
X_valid, y_valid = self.validation[0], self.validation[1]
y_pred = self.model.predict(X_valid)
val_score = mse(y_pred, y_valid)
logs['my_metric_val'] = np.round(val_score, 5)
def build_model():
inp1 = Input((5,))
inp2 = Input((5,))
out = Concatenate()([inp1, inp2])
out = Dense(1)(out)
model = Model([inp1, inp2], out)
model.compile(loss='mse', optimizer='adam')
return model
X_train1 = np.random.uniform(0,1, (100,5))
X_train2 = np.random.uniform(0,1, (100,5))
y_train = np.random.uniform(0,1, (100,1))
X_val1 = np.random.uniform(0,1, (100,5))
X_val2 = np.random.uniform(0,1, (100,5))
y_val = np.random.uniform(0,1, (100,1))
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train), validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train))])
-----------------------
class MyCustomMetricCallback(tf.keras.callbacks.Callback):
def __init__(self, train=None, validation=None):
super(MyCustomMetricCallback, self).__init__()
self.train = train
self.validation = validation
def on_epoch_end(self, epoch, logs={}):
mse = tf.keras.losses.mean_squared_error
if self.train:
logs['my_metric_train'] = float('inf')
X_train, y_train = self.train[0], self.train[1]
y_pred = self.model.predict(X_train)
score = mse(y_train, y_pred)
logs['my_metric_train'] = np.round(score, 5)
if self.validation:
logs['my_metric_val'] = float('inf')
X_valid, y_valid = self.validation[0], self.validation[1]
y_pred = self.model.predict(X_valid)
val_score = mse(y_pred, y_valid)
logs['my_metric_val'] = np.round(val_score, 5)
def build_model():
inp1 = Input((5,))
inp2 = Input((5,))
out = Concatenate()([inp1, inp2])
out = Dense(1)(out)
model = Model([inp1, inp2], out)
model.compile(loss='mse', optimizer='adam')
return model
X_train1 = np.random.uniform(0,1, (100,5))
X_train2 = np.random.uniform(0,1, (100,5))
y_train = np.random.uniform(0,1, (100,1))
X_val1 = np.random.uniform(0,1, (100,5))
X_val2 = np.random.uniform(0,1, (100,5))
y_val = np.random.uniform(0,1, (100,1))
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train), validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train))])
-----------------------
class MyCustomMetricCallback(tf.keras.callbacks.Callback):
def __init__(self, train=None, validation=None):
super(MyCustomMetricCallback, self).__init__()
self.train = train
self.validation = validation
def on_epoch_end(self, epoch, logs={}):
mse = tf.keras.losses.mean_squared_error
if self.train:
logs['my_metric_train'] = float('inf')
X_train, y_train = self.train[0], self.train[1]
y_pred = self.model.predict(X_train)
score = mse(y_train, y_pred)
logs['my_metric_train'] = np.round(score, 5)
if self.validation:
logs['my_metric_val'] = float('inf')
X_valid, y_valid = self.validation[0], self.validation[1]
y_pred = self.model.predict(X_valid)
val_score = mse(y_pred, y_valid)
logs['my_metric_val'] = np.round(val_score, 5)
def build_model():
inp1 = Input((5,))
inp2 = Input((5,))
out = Concatenate()([inp1, inp2])
out = Dense(1)(out)
model = Model([inp1, inp2], out)
model.compile(loss='mse', optimizer='adam')
return model
X_train1 = np.random.uniform(0,1, (100,5))
X_train2 = np.random.uniform(0,1, (100,5))
y_train = np.random.uniform(0,1, (100,1))
X_val1 = np.random.uniform(0,1, (100,5))
X_val2 = np.random.uniform(0,1, (100,5))
y_val = np.random.uniform(0,1, (100,1))
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train), validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train))])
-----------------------
class MyCustomMetricCallback(tf.keras.callbacks.Callback):
def __init__(self, train=None, validation=None):
super(MyCustomMetricCallback, self).__init__()
self.train = train
self.validation = validation
def on_epoch_end(self, epoch, logs={}):
mse = tf.keras.losses.mean_squared_error
if self.train:
logs['my_metric_train'] = float('inf')
X_train, y_train = self.train[0], self.train[1]
y_pred = self.model.predict(X_train)
score = mse(y_train, y_pred)
logs['my_metric_train'] = np.round(score, 5)
if self.validation:
logs['my_metric_val'] = float('inf')
X_valid, y_valid = self.validation[0], self.validation[1]
y_pred = self.model.predict(X_valid)
val_score = mse(y_pred, y_valid)
logs['my_metric_val'] = np.round(val_score, 5)
def build_model():
inp1 = Input((5,))
inp2 = Input((5,))
out = Concatenate()([inp1, inp2])
out = Dense(1)(out)
model = Model([inp1, inp2], out)
model.compile(loss='mse', optimizer='adam')
return model
X_train1 = np.random.uniform(0,1, (100,5))
X_train2 = np.random.uniform(0,1, (100,5))
y_train = np.random.uniform(0,1, (100,1))
X_val1 = np.random.uniform(0,1, (100,5))
X_val2 = np.random.uniform(0,1, (100,5))
y_val = np.random.uniform(0,1, (100,1))
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train), validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train))])
-----------------------
class MyCustomMetricCallback(tf.keras.callbacks.Callback):
def __init__(self, train=None, validation=None):
super(MyCustomMetricCallback, self).__init__()
self.train = train
self.validation = validation
def on_epoch_end(self, epoch, logs={}):
mse = tf.keras.losses.mean_squared_error
if self.train:
logs['my_metric_train'] = float('inf')
X_train, y_train = self.train[0], self.train[1]
y_pred = self.model.predict(X_train)
score = mse(y_train, y_pred)
logs['my_metric_train'] = np.round(score, 5)
if self.validation:
logs['my_metric_val'] = float('inf')
X_valid, y_valid = self.validation[0], self.validation[1]
y_pred = self.model.predict(X_valid)
val_score = mse(y_pred, y_valid)
logs['my_metric_val'] = np.round(val_score, 5)
def build_model():
inp1 = Input((5,))
inp2 = Input((5,))
out = Concatenate()([inp1, inp2])
out = Dense(1)(out)
model = Model([inp1, inp2], out)
model.compile(loss='mse', optimizer='adam')
return model
X_train1 = np.random.uniform(0,1, (100,5))
X_train2 = np.random.uniform(0,1, (100,5))
y_train = np.random.uniform(0,1, (100,1))
X_val1 = np.random.uniform(0,1, (100,5))
X_val2 = np.random.uniform(0,1, (100,5))
y_val = np.random.uniform(0,1, (100,1))
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train), validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(validation=([X_val1, X_val2],y_val))])
model = build_model()
model.fit([X_train1, X_train2], y_train, epochs=10,
callbacks=[MyCustomMetricCallback(train=([X_train1, X_train2],y_train))])
Keras AttributeError: 'Sequential' object has no attribute 'predict_classes'
predict_x=model.predict(X_test)
classes_x=np.argmax(predict_x,axis=1)
-----------------------
y_pred = model.predict(X_test)
y_pred = np.round(y_pred).astype(int)
-----------------------
predictions = model.predict_classess(x_test)
predictions = (model.predict(x_test) > 0.5).astype("int32")
-----------------------
predictions = model.predict_classess(x_test)
predictions = (model.predict(x_test) > 0.5).astype("int32")
-----------------------
y_predict = np.argmax(model.predict(x_test), axis=-1)
-----------------------
predicted = np.argmax(model.predict(token_list),axis=1)
-----------------------
predictions = (model.predict(X_test) > 0.5)*1
cannot import name '_registerMatType' from 'cv2.cv2'
C:\Windows\system32>pip list |findstr opencv
opencv-python 4.5.2.52
opencv-python-headless 4.5.5.62
pip uninstall opencv-python-headless==4.5.5.62
pip install opencv-python-headless==4.5.2.52
-----------------------
C:\Windows\system32>pip list |findstr opencv
opencv-python 4.5.2.52
opencv-python-headless 4.5.5.62
pip uninstall opencv-python-headless==4.5.5.62
pip install opencv-python-headless==4.5.2.52
-----------------------
C:\Windows\system32>pip list |findstr opencv
opencv-python 4.5.2.52
opencv-python-headless 4.5.5.62
pip uninstall opencv-python-headless==4.5.5.62
pip install opencv-python-headless==4.5.2.52
-----------------------
C:\Windows\system32>pip list |findstr opencv
opencv-python 4.5.2.52
opencv-python-headless 4.5.5.62
-----------------------
pip uninstall opencv-python
pip install opencv-python
-----------------------
pip list | grep opencv
opencv-contrib-python 4.5.3.56
opencv-python 4.5.5.62
python -m pip install --upgrade opencv-contrib-python
-----------------------
pip list | grep opencv
opencv-contrib-python 4.5.3.56
opencv-python 4.5.5.62
python -m pip install --upgrade opencv-contrib-python
-----------------------
pip list | grep opencv
opencv-contrib-python 4.5.3.56
opencv-python 4.5.5.62
python -m pip install --upgrade opencv-contrib-python
How to measure energy usage in Xcode 13 / iOS15?
import MetricKit
...
// Somewhere in your application startup sequence:
MXMetricManager.shared.add(someObjectYouWantToHaveThisResponsibility)
...
extension SomeObjectYouWantToHaveThisResponsibility: MXMetricManagerSubscriber {
func didReceive(_ payloads: [MXMetricPayload]) {
for payload in payloads {
// Parse the payload here
}
}
}
When recognizing hand gesture classes, I always get the same class in Keras
feature1, feature2, feature3,y
aaa,bbb,3.0,2.0
bbb, ,4.1, 3.1
-----------------------
import tensorflow as tf
import pandas as pd
df_train = pd.read_csv('/content/training_set.csv', skiprows=1, index_col=0)
df_train = df_train.fillna(0)
x_train = df_train.drop(['138.1', '0.1'], axis=1)
y_train = df_train['138.1']
x_train = x_train / 310
y_train_cat = tf.keras.utils.to_categorical(y_train, 6)
model = tf.keras.Sequential([tf.keras.layers.Dense(64, input_shape=(41,), activation='relu'),
tf.keras.layers.Dense(32, activation='relu'),
tf.keras.layers.Dense(6, activation='softmax')])
model.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, y_train_cat, batch_size=16, epochs=9, validation_split=0.2)
model.save("gestures_model.h5")
REV_CLASS_MAP = {
0: "up",
1: "down",
2: "right",
3: "left",
4: "forward",
5: "back"
}
def mapper(val):
return REV_CLASS_MAP[val]
df_test = pd.read_csv('/content/testing_set.csv', skiprows=1, index_col=0)
df_test = df_test.fillna(0)
x_test = df_test.drop(['140', '0.1'], axis=1)
y_test = df_test['140']
model = tf.keras.models.load_model("/content/gestures_model.h5")
predicted_list = model.predict(x_test)
print(tf.argmax(predicted_list, axis=-1))
tf.Tensor(
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4 4 4 4 4 4 1 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4
4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
3 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0
0 0 0 1 1 0 0 4 4 4 0 4 4 4 4 4 4 4 3 4 4 4 4 4 4 4 4 4 1 1 1 3 4 4 4 4 1
1 1 4 1 1 1 4], shape=(599,), dtype=int64)
-----------------------
import tensorflow as tf
import pandas as pd
df_train = pd.read_csv('/content/training_set.csv', skiprows=1, index_col=0)
df_train = df_train.fillna(0)
x_train = df_train.drop(['138.1', '0.1'], axis=1)
y_train = df_train['138.1']
x_train = x_train / 310
y_train_cat = tf.keras.utils.to_categorical(y_train, 6)
model = tf.keras.Sequential([tf.keras.layers.Dense(64, input_shape=(41,), activation='relu'),
tf.keras.layers.Dense(32, activation='relu'),
tf.keras.layers.Dense(6, activation='softmax')])
model.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, y_train_cat, batch_size=16, epochs=9, validation_split=0.2)
model.save("gestures_model.h5")
REV_CLASS_MAP = {
0: "up",
1: "down",
2: "right",
3: "left",
4: "forward",
5: "back"
}
def mapper(val):
return REV_CLASS_MAP[val]
df_test = pd.read_csv('/content/testing_set.csv', skiprows=1, index_col=0)
df_test = df_test.fillna(0)
x_test = df_test.drop(['140', '0.1'], axis=1)
y_test = df_test['140']
model = tf.keras.models.load_model("/content/gestures_model.h5")
predicted_list = model.predict(x_test)
print(tf.argmax(predicted_list, axis=-1))
tf.Tensor(
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4 4 4 4 4 4 1 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4
4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
3 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0
0 0 0 1 1 0 0 4 4 4 0 4 4 4 4 4 4 4 3 4 4 4 4 4 4 4 4 4 1 1 1 3 4 4 4 4 1
1 1 4 1 1 1 4], shape=(599,), dtype=int64)
-----------------------
import tensorflow as tf
import pandas as pd
df_train = pd.read_csv('/content/training_set.csv', skiprows=1, index_col=0)
df_train = df_train.fillna(0)
x_train = df_train.drop(['138.1', '0.1'], axis=1)
y_train = df_train['138.1']
x_train = x_train / 310
y_train_cat = tf.keras.utils.to_categorical(y_train, 6)
model = tf.keras.Sequential([tf.keras.layers.Dense(64, input_shape=(41,), activation='relu'),
tf.keras.layers.Dense(32, activation='relu'),
tf.keras.layers.Dense(6, activation='softmax')])
model.compile(optimizer='adam',
loss='categorical_crossentropy',
metrics=['accuracy'])
model.fit(x_train, y_train_cat, batch_size=16, epochs=9, validation_split=0.2)
model.save("gestures_model.h5")
REV_CLASS_MAP = {
0: "up",
1: "down",
2: "right",
3: "left",
4: "forward",
5: "back"
}
def mapper(val):
return REV_CLASS_MAP[val]
df_test = pd.read_csv('/content/testing_set.csv', skiprows=1, index_col=0)
df_test = df_test.fillna(0)
x_test = df_test.drop(['140', '0.1'], axis=1)
y_test = df_test['140']
model = tf.keras.models.load_model("/content/gestures_model.h5")
predicted_list = model.predict(x_test)
print(tf.argmax(predicted_list, axis=-1))
tf.Tensor(
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 3 4 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 4 4 4 4 4 4 4 4 1 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
1 1 1 1 1 1 1 1 1 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4
4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 2 2 2 2 2 2 2 2 2 2 4 4 4 4 4 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2 2
2 2 2 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3
3 4 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 3 3 3 3 3 3 3
3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 3 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4
4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 3 3 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 4 0
0 0 0 1 1 0 0 4 4 4 0 4 4 4 4 4 4 4 3 4 4 4 4 4 4 4 4 4 1 1 1 3 4 4 4 4 1
1 1 4 1 1 1 4], shape=(599,), dtype=int64)
Spring Boot WebClient stops sending requests
jstack <java pid> > ThredDump.txt
-----------------------
"reactor-http-epoll-6@15467" daemon prio=5 tid=0xbe nid=NA waiting
java.lang.Thread.State: WAITING
at jdk.internal.misc.Unsafe.park(Unsafe.java:-1)
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:194)
at java.util.concurrent.CompletableFuture$Signaller.block(CompletableFuture.java:1796)
Add Kubernetes scrape target to Prometheus instance that is NOT in Kubernetes
- job_name: kubernetes
kubernetes_sd_configs:
- role: node
api_server: https://kubernetes-cluster-api.com
tls_config:
insecure_skip_verify: true
bearer_token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
bearer_token: "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
scheme: https
tls_config:
insecure_skip_verify: true
relabel_configs:
- separator: ;
regex: __meta_kubernetes_node_label_(.+)
replacement: $1
action: labelmap
-----------------------
- job_name: 'kubelet-cadvisor'
scheme: https
kubernetes_sd_configs:
- role: node
api_server: https://api-server.example.com
# TLS and auth settings to perform service discovery
authorization:
credentials_file: /kube/token # the file with your service account token
tls_config:
ca_file: /kube/CA.crt # the file with the CA certificate
# The same as above but for actual scrape request.
# We're going to send scrape requests back to the API-server
# so the credentials are the same.
bearer_token_file: /kube/token
tls_config:
ca_file: /kube/CA.crt
relabel_configs:
# This is just to drop this long __meta_kubernetes_node_label_ prefix
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
# By default Prometheus goes to /metrics endpoint.
# This relabeling changes it to /api/v1/nodes/[kubernetes_io_hostname]/proxy/metrics/cadvisor
- source_labels: [kubernetes_io_hostname]
replacement: /api/v1/nodes/$1/proxy/metrics/cadvisor
target_label: __metrics_path__
# This relabeling defines that Prometheus should connect to the
# API-server instead of the actual instance. Together with the relabeling
# from above this will make the scrape request proxied to the node kubelet.
- replacement: api-server.example.com
target_label: __address__
❯ kubectl config view --raw
apiVersion: v1
clusters:
- cluster: # you need this ⤋ long value
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJ...
server: https://api-server.example.com
name: default
...
echo LS0tLS1CRUdJTiBDRVJUSUZJ... | base64 -d > CA.crt
-----------------------
- job_name: 'kubelet-cadvisor'
scheme: https
kubernetes_sd_configs:
- role: node
api_server: https://api-server.example.com
# TLS and auth settings to perform service discovery
authorization:
credentials_file: /kube/token # the file with your service account token
tls_config:
ca_file: /kube/CA.crt # the file with the CA certificate
# The same as above but for actual scrape request.
# We're going to send scrape requests back to the API-server
# so the credentials are the same.
bearer_token_file: /kube/token
tls_config:
ca_file: /kube/CA.crt
relabel_configs:
# This is just to drop this long __meta_kubernetes_node_label_ prefix
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
# By default Prometheus goes to /metrics endpoint.
# This relabeling changes it to /api/v1/nodes/[kubernetes_io_hostname]/proxy/metrics/cadvisor
- source_labels: [kubernetes_io_hostname]
replacement: /api/v1/nodes/$1/proxy/metrics/cadvisor
target_label: __metrics_path__
# This relabeling defines that Prometheus should connect to the
# API-server instead of the actual instance. Together with the relabeling
# from above this will make the scrape request proxied to the node kubelet.
- replacement: api-server.example.com
target_label: __address__
❯ kubectl config view --raw
apiVersion: v1
clusters:
- cluster: # you need this ⤋ long value
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJ...
server: https://api-server.example.com
name: default
...
echo LS0tLS1CRUdJTiBDRVJUSUZJ... | base64 -d > CA.crt
-----------------------
- job_name: 'kubelet-cadvisor'
scheme: https
kubernetes_sd_configs:
- role: node
api_server: https://api-server.example.com
# TLS and auth settings to perform service discovery
authorization:
credentials_file: /kube/token # the file with your service account token
tls_config:
ca_file: /kube/CA.crt # the file with the CA certificate
# The same as above but for actual scrape request.
# We're going to send scrape requests back to the API-server
# so the credentials are the same.
bearer_token_file: /kube/token
tls_config:
ca_file: /kube/CA.crt
relabel_configs:
# This is just to drop this long __meta_kubernetes_node_label_ prefix
- action: labelmap
regex: __meta_kubernetes_node_label_(.+)
# By default Prometheus goes to /metrics endpoint.
# This relabeling changes it to /api/v1/nodes/[kubernetes_io_hostname]/proxy/metrics/cadvisor
- source_labels: [kubernetes_io_hostname]
replacement: /api/v1/nodes/$1/proxy/metrics/cadvisor
target_label: __metrics_path__
# This relabeling defines that Prometheus should connect to the
# API-server instead of the actual instance. Together with the relabeling
# from above this will make the scrape request proxied to the node kubelet.
- replacement: api-server.example.com
target_label: __address__
❯ kubectl config view --raw
apiVersion: v1
clusters:
- cluster: # you need this ⤋ long value
certificate-authority-data: LS0tLS1CRUdJTiBDRVJUSUZJ...
server: https://api-server.example.com
name: default
...
echo LS0tLS1CRUdJTiBDRVJUSUZJ... | base64 -d > CA.crt
Saving model on Tensorflow 2.7.0 with data augmentation layer
import tensorflow as tf
import numpy as np
class RandomColorDistortion(tf.keras.layers.Layer):
def __init__(self, contrast_range=[0.5, 1.5],
brightness_delta=[-0.2, 0.2], **kwargs):
super(RandomColorDistortion, self).__init__(**kwargs)
self.contrast_range = contrast_range
self.brightness_delta = brightness_delta
def call(self, images, training=None):
if not training:
return images
contrast = np.random.uniform(
self.contrast_range[0], self.contrast_range[1])
brightness = np.random.uniform(
self.brightness_delta[0], self.brightness_delta[1])
images = tf.image.adjust_contrast(images, contrast)
images = tf.image.adjust_brightness(images, brightness)
images = tf.clip_by_value(images, 0, 1)
return images
def get_config(self):
config = super(RandomColorDistortion, self).get_config()
config.update({"contrast_range": self.contrast_range, "brightness_delta": self.brightness_delta})
return config
input_shape_rgb = (256, 256, 3)
data_augmentation_rgb = tf.keras.Sequential(
[
tf.keras.layers.RandomFlip("horizontal"),
tf.keras.layers.RandomFlip("vertical"),
tf.keras.layers.RandomRotation(0.5),
tf.keras.layers.RandomZoom(0.5),
tf.keras.layers.RandomContrast(0.5),
RandomColorDistortion(name='random_contrast_brightness/none'),
]
)
input_shape = (256, 256, 3)
padding = 'same'
kernel_size = 3
model = tf.keras.Sequential([
tf.keras.layers.Input(input_shape),
data_augmentation_rgb,
tf.keras.layers.Rescaling((1./255)),
tf.keras.layers.Conv2D(16, kernel_size, padding=padding, activation='relu', strides=1,
data_format='channels_last'),
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Conv2D(32, kernel_size, padding=padding, activation='relu'), # best 4
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Conv2D(64, kernel_size, padding=padding, activation='relu'), # best 3
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Conv2D(128, kernel_size, padding=padding, activation='relu'), # best 3
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(128, activation='relu'), # best 1
tf.keras.layers.Dropout(0.1),
tf.keras.layers.Dense(128, activation='relu'), # best 1
tf.keras.layers.Dropout(0.1),
tf.keras.layers.Dense(64, activation='relu'), # best 1
tf.keras.layers.Dropout(0.1),
tf.keras.layers.Dense(5, activation = 'softmax')
])
model.compile(loss='categorical_crossentropy', optimizer='adam')
model.summary()
model.save("test", save_format='h5')
model = tf.keras.models.load_model('test.h5', custom_objects={'RandomColorDistortion': RandomColorDistortion})
-----------------------
import tensorflow as tf
import numpy as np
class RandomColorDistortion(tf.keras.layers.Layer):
def __init__(self, contrast_range=[0.5, 1.5],
brightness_delta=[-0.2, 0.2], **kwargs):
super(RandomColorDistortion, self).__init__(**kwargs)
self.contrast_range = contrast_range
self.brightness_delta = brightness_delta
def call(self, images, training=None):
if not training:
return images
contrast = np.random.uniform(
self.contrast_range[0], self.contrast_range[1])
brightness = np.random.uniform(
self.brightness_delta[0], self.brightness_delta[1])
images = tf.image.adjust_contrast(images, contrast)
images = tf.image.adjust_brightness(images, brightness)
images = tf.clip_by_value(images, 0, 1)
return images
def get_config(self):
config = super(RandomColorDistortion, self).get_config()
config.update({"contrast_range": self.contrast_range, "brightness_delta": self.brightness_delta})
return config
input_shape_rgb = (256, 256, 3)
data_augmentation_rgb = tf.keras.Sequential(
[
tf.keras.layers.RandomFlip("horizontal"),
tf.keras.layers.RandomFlip("vertical"),
tf.keras.layers.RandomRotation(0.5),
tf.keras.layers.RandomZoom(0.5),
tf.keras.layers.RandomContrast(0.5),
RandomColorDistortion(name='random_contrast_brightness/none'),
]
)
input_shape = (256, 256, 3)
padding = 'same'
kernel_size = 3
model = tf.keras.Sequential([
tf.keras.layers.Input(input_shape),
data_augmentation_rgb,
tf.keras.layers.Rescaling((1./255)),
tf.keras.layers.Conv2D(16, kernel_size, padding=padding, activation='relu', strides=1,
data_format='channels_last'),
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Conv2D(32, kernel_size, padding=padding, activation='relu'), # best 4
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Conv2D(64, kernel_size, padding=padding, activation='relu'), # best 3
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Conv2D(128, kernel_size, padding=padding, activation='relu'), # best 3
tf.keras.layers.MaxPooling2D(),
tf.keras.layers.BatchNormalization(),
tf.keras.layers.Flatten(),
tf.keras.layers.Dense(128, activation='relu'), # best 1
tf.keras.layers.Dropout(0.1),
tf.keras.layers.Dense(128, activation='relu'), # best 1
tf.keras.layers.Dropout(0.1),
tf.keras.layers.Dense(64, activation='relu'), # best 1
tf.keras.layers.Dropout(0.1),
tf.keras.layers.Dense(5, activation = 'softmax')
])
model.compile(loss='categorical_crossentropy', optimizer='adam')
model.summary()
model.save("test", save_format='h5')
model = tf.keras.models.load_model('test.h5', custom_objects={'RandomColorDistortion': RandomColorDistortion})
get cloudfront usage report via aws cli
aws ce get-cost-and-usage \
--time-period Start=2022-01-01,End=2022-01-03 \
--granularity MONTHLY \
--metrics "BlendedCost" "UnblendedCost" "UsageQuantity" \
--group-by Type=DIMENSION,Key=SERVICE Type=TAG,Key=Environment
-----------------------
curl 'https://console.aws.amazon.com/cloudfront/v3/api/cloudfrontreporting' \
-H 'authority: console.aws.amazon.com' \
-H 'sec-ch-ua: " Not;A Brand";v="99", "Google Chrome";v="97", "Chromium";v="97"' \
-H 'content-type: application/json' \
-H 'x-csrf-token: ${CSRF_TOKEN}' \
-H 'accept: */*' \
-H 'origin: https://console.aws.amazon.com' \
-H 'sec-fetch-site: same-origin' \
-H 'sec-fetch-mode: cors' \
-H 'sec-fetch-dest: empty' \
-H 'referer: https://console.aws.amazon.com/cloudfront/v3/home?region=eu-central-1' \
-H 'accept-language: en-US,en;q=0.9' \
-H 'cookie: ${COOKIE}' \
--data-raw '{"headers":{"X-Amz-User-Agent":"aws-sdk-js/2.849.0 promise"},"path":"/2014-01-01/reports/series","method":"POST","region":"us-east-1","params":{},"contentString":"<DataPointSeriesRequestFilters xmlns=\"http://cloudfront.amazonaws.com/doc/2014-01-01/\"><Report>Usage</Report><StartTime>2022-01-28T11:23:35Z</StartTime><EndTime>2022-02-04T11:23:35Z</EndTime><TimeBucketSizeMinutes>ONE_DAY</TimeBucketSizeMinutes><ResourceId>All Web Distributions (excludes deleted)</ResourceId><Region>ALL</Region><Series><DataKey><Name>HTTP</Name><Description></Description></DataKey><DataKey><Name>HTTPS</Name><Description></Description></DataKey><DataKey><Name>HTTP-BYTES</Name><Description></Description></DataKey><DataKey><Name>HTTPS-BYTES</Name><Description></Description></DataKey><DataKey><Name>BYTES-OUT</Name><Description></Description></DataKey><DataKey><Name>BYTES-IN</Name><Description></Description></DataKey><DataKey><Name>FLE</Name><Description></Description></DataKey></Series></DataPointSeriesRequestFilters>","operation":"listDataPointSeries"}' \
--compressed > report.xml
QUESTION
Microk8s dashboard using nginx-ingress via http not working (Error: `no matches for kind "Ingress" in version "extensions/v1beta1"`)
Asked 2022-Apr-01 at 07:26I have microk8s v1.22.2 running on Ubuntu 20.04.3 LTS.
Output from /etc/hosts
:
127.0.0.1 localhost
127.0.1.1 main
Excerpt from microk8s status
:
addons:
enabled:
dashboard # The Kubernetes dashboard
ha-cluster # Configure high availability on the current node
ingress # Ingress controller for external access
metrics-server # K8s Metrics Server for API access to service metrics
I checked for the running dashboard (kubectl get all --all-namespaces
):
NAMESPACE NAME READY STATUS RESTARTS AGE
kube-system pod/calico-node-2jltr 1/1 Running 0 23m
kube-system pod/calico-kube-controllers-f744bf684-d77hv 1/1 Running 0 23m
kube-system pod/metrics-server-85df567dd8-jd6gj 1/1 Running 0 22m
kube-system pod/kubernetes-dashboard-59699458b-pb5jb 1/1 Running 0 21m
kube-system pod/dashboard-metrics-scraper-58d4977855-94nsp 1/1 Running 0 21m
ingress pod/nginx-ingress-microk8s-controller-qf5pm 1/1 Running 0 21m
NAMESPACE NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
default service/kubernetes ClusterIP 10.152.183.1 <none> 443/TCP 23m
kube-system service/metrics-server ClusterIP 10.152.183.81 <none> 443/TCP 22m
kube-system service/kubernetes-dashboard ClusterIP 10.152.183.103 <none> 443/TCP 22m
kube-system service/dashboard-metrics-scraper ClusterIP 10.152.183.197 <none> 8000/TCP 22m
NAMESPACE NAME DESIRED CURRENT READY UP-TO-DATE AVAILABLE NODE SELECTOR AGE
kube-system daemonset.apps/calico-node 1 1 1 1 1 kubernetes.io/os=linux 23m
ingress daemonset.apps/nginx-ingress-microk8s-controller 1 1 1 1 1 <none> 22m
NAMESPACE NAME READY UP-TO-DATE AVAILABLE AGE
kube-system deployment.apps/calico-kube-controllers 1/1 1 1 23m
kube-system deployment.apps/metrics-server 1/1 1 1 22m
kube-system deployment.apps/kubernetes-dashboard 1/1 1 1 22m
kube-system deployment.apps/dashboard-metrics-scraper 1/1 1 1 22m
NAMESPACE NAME DESIRED CURRENT READY AGE
kube-system replicaset.apps/calico-kube-controllers-69d7f794d9 0 0 0 23m
kube-system replicaset.apps/calico-kube-controllers-f744bf684 1 1 1 23m
kube-system replicaset.apps/metrics-server-85df567dd8 1 1 1 22m
kube-system replicaset.apps/kubernetes-dashboard-59699458b 1 1 1 21m
kube-system replicaset.apps/dashboard-metrics-scraper-58d4977855 1 1 1 21m
I want to expose the microk8s dashboard within my local network to access it through http://main/dashboard/
To do so, I did the following nano ingress.yaml
:
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
annotations:
kubernetes.io/ingress.class: public
nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
name: dashboard
namespace: kube-system
spec:
rules:
- host: main
http:
paths:
- backend:
serviceName: kubernetes-dashboard
servicePort: 443
path: /
Enabling the ingress-config through kubectl apply -f ingress.yaml
gave the following error:
error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
Help would be much appreciated, thanks!
Update: @harsh-manvar pointed out a mismatch in the config version. I have rewritten ingress.yaml to a very stripped down version:
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: dashboard
namespace: kube-system
spec:
rules:
- http:
paths:
- path: /dashboard
pathType: Prefix
backend:
service:
name: kubernetes-dashboard
port:
number: 443
Applying this works. Also, the ingress rule gets created.
NAMESPACE NAME CLASS HOSTS ADDRESS PORTS AGE
kube-system dashboard public * 127.0.0.1 80 11m
However, when I access the dashboard through http://<ip-of-kubernetes-master>/dashboard
, I get a 400
error.
Log from the ingress controller:
192.168.0.123 - - [10/Oct/2021:21:38:47 +0000] "GET /dashboard HTTP/1.1" 400 54 "-" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36" 466 0.002 [kube-system-kubernetes-dashboard-443] [] 10.1.76.3:8443 48 0.000 400 ca0946230759edfbaaf9d94f3d5c959a
Does the dashboard also need to be exposed using the microk8s proxy
? I thought the ingress controller would take care of this, or did I misunderstand this?
ANSWER
Answered 2021-Oct-10 at 18:29error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
it' due to the mismatch in the ingress API version.
You are running the v1.22.2 while API version in YAML is old.
Good example : https://kubernetes.io/docs/tasks/access-application-cluster/ingress-minikube/
you are using the older ingress API version in your YAML which is extensions/v1beta1
.
You need to change this based on ingress version and K8s version you are running.
This is for version 1.19 in K8s and will work in 1.22 also
Example :
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: minimal-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- http:
paths:
- path: /testpath
pathType: Prefix
backend:
service:
name: test
port:
number: 80
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
No vulnerabilities reported
Save this library and start creating your kit
Explore Related Topics
Save this library and start creating your kit