Explore all Dashboard open source software, libraries, packages, source code, cloud functions and APIs.

Popular New Releases in Dashboard

grafana

8.5.0 (2022-04-21)

AdminLTE

AdminLTE v3.2.0

ngx-admin

v6.0.0

kibana

Kibana 8.1.3

appsmith

Release v1.6.20 🌈

Popular Libraries in Dashboard

grafana

by grafana doticontypescriptdoticon

star image 48159 doticonAGPL-3.0

The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.

AdminLTE

by ColorlibHQ doticonjavascriptdoticon

star image 40777 doticonMIT

AdminLTE - Free admin dashboard template based on Bootstrap 4

ngx-admin

by akveo doticontypescriptdoticon

star image 22994 doticonMIT

Customizable admin dashboard template based on Angular 10+

kibana

by elastic doticontypescriptdoticon

star image 17328 doticonNOASSERTION

Your window into the Elastic Stack

appsmith

by appsmithorg doticontypescriptdoticon

star image 15181 doticonApache-2.0

Low code project to build admin panels, internal tools, and dashboards. Integrates with 15+ databases and any API.

webpack-dashboard

by FormidableLabs doticonjavascriptdoticon

star image 13873 doticonMIT

A CLI dashboard for webpack dev server

blur-admin

by akveo doticonjavascriptdoticon

star image 11220 doticonNOASSERTION

AngularJS Bootstrap Admin Panel Framework

coreui-free-bootstrap-admin-template

by coreui doticonhtmldoticon

star image 11139 doticonMIT

Free Bootstrap 5 admin & dashboard template

dashing

by Shopify doticonjavascriptdoticon

star image 11116 doticonMIT

The exceptionally handsome dashboard framework in Ruby and Coffeescript.

Trending New libraries in Dashboard

appsmith

by appsmithorg doticontypescriptdoticon

star image 15181 doticonApache-2.0

Low code project to build admin panels, internal tools, and dashboards. Integrates with 15+ databases and any API.

wave

by h2oai doticonpythondoticon

star image 2885 doticonApache-2.0

Realtime Web Apps and Dashboards for Python and R

tempo

by grafana doticongodoticon

star image 1958 doticonAGPL-3.0

Grafana Tempo is a high volume, minimal dependency distributed tracing backend.

react-saas-template

by dunky11 doticonjavascriptdoticon

star image 1480 doticonMIT

🌊 Template for building an SaaS / admin website using React + Material-UI

motor-admin

by motor-admin doticonrubydoticon

star image 1172 doticonAGPL-3.0

Deploy a no-code admin panel for any application in less than a minute. Search, create, update, and delete data entries, create custom actions, and build reports.

querybook

by pinterest doticontypescriptdoticon

star image 1139 doticonApache-2.0

Querybook is a Big Data Querying UI, combining collocated table metadata and a simple notebook interface.

django-jazzmin

by farridav doticonhtmldoticon

star image 983 doticonMIT

Jazzy theme for Django

KubePi

by KubeOperator doticongodoticon

star image 944 doticonApache-2.0

KubePi 是一款简单易用的开源 Kubernetes 可视化管理面板

DashMachine

by rmountjoy92 doticonpythondoticon

star image 884 doticonGPL-3.0

Another web application bookmark dashboard, with fun features.

Top Authors in Dashboard

1

app-generator

50 Libraries

star icon1943

2

grafana

35 Libraries

star icon53005

3

creativetimofficial

19 Libraries

star icon15843

4

bugsnag

18 Libraries

star icon4290

5

allure-framework

18 Libraries

star icon4151

6

BootstrapDash

14 Libraries

star icon2292

7

mozilla

13 Libraries

star icon57

8

MindscapeHQ

11 Libraries

star icon446

9

DevExpress

11 Libraries

star icon477

10

puikinsh

11 Libraries

star icon10062

1

50 Libraries

star icon1943

2

35 Libraries

star icon53005

3

19 Libraries

star icon15843

4

18 Libraries

star icon4290

5

18 Libraries

star icon4151

6

14 Libraries

star icon2292

7

13 Libraries

star icon57

8

11 Libraries

star icon446

9

11 Libraries

star icon477

10

11 Libraries

star icon10062

Trending Kits in Dashboard

Python Dashboard library offers graphs, maps, charts, and tables. Dashboards can be interactive by adding sliders, drop-down lists and buttons. 


It can update the visualizations dynamically. These libraries often offer options for customizing the dashboard's layout, styles, and colors to match specific design requirements. Dashboards can be deployed locally or on the web using a cloud-based platform or a built-in server. These dashboards can integrate with different data sources like APIs, spreadsheets, and databases, making it easier to update the data in real-time. Different users can share and access it through password-protected logins or public URLs. These libraries can come with extensive documentation and community support making it easier to get started and troubleshoot any issues.   


Here is the list of the top 17 Python Dashboard libraries that are handpicked to help developers: 

redash: 

  • Is an open source visualization and dashboard platform which will allow users to connect and visualize the data from different sources, like APIs, third-party services, and databases.  
  • Is a web-based platform that can be accessed through a browser and is built using JavaScript and Python.  
  • Offers a simple and intuitive interface to create and share data visualization, which can be customized to be suitable for individual requirements.   

plotly.py: 

  • Is a Python Data visualization that can be used for creating interactive, publication-quality graphs and charts.   
  • Allows the creation of interactive visualizations with hover, zoom, and click events, making it easy to explore and analyze data in real time.  
  • Allows customization of each aspect of a chart, like fonts, titles, colors, and axis labels.   

flask_jsondash: 

  • Is a flask extension to create dashboards and visualizations in Python designed to be customizable, allowing developers to create their own dashboard layouts and widgets.  
  • Create custom widgets that interact with the data in real-time, like drop-down lists, buttons, and sliders.  
  • Is a good choice for developers creating simple, lightweight dashboards, and visualizations in Python, without learning a more complex framework.   

wave: 

  • Is a Python library to build and deploy interactive, web-based dashboards for data exploration and visualization.   
  • Integrates seamlessly with H2O.ai's machine learning platform, allowing users to visualize and explore machine learning models.  
  • Offers features for sharing and collaboration, like the ability to share dashboards with others and collaborate on projects. 

psdash: 

  • Is a Python-based web dashboard for real-time monitoring of process statistics, system resource utilization, and other system-related information.   
  • Can be used for identifying and troubleshooting issues, optimizing system performance, and performance bottlenecks.  
  • Offers real-time updates of process and system statistics with the ability to refresh data at a customizable interval.   

panel: 

  • Is a Python library to create interactive web dashboards and applications and offers a high-level API.  
  • Supports different backends like Matplotlib, Holoviews, Bokeh, and Plotly, allowing developers to use their preferred plotting library.  
  • Offers reactive widgets that can update in real-time based on user input, allowing interactive and dynamic applications to be created. 

stashboard: 

  • Offers a user-friendly interface to monitor system health, uptime, and other key metrics, which can be used to notify users of system issues in real-time.  
  • Can be used for monitoring APIs, web services, and other software systems with support for SOAP, REST, and other protocols.  
  • Offers custom metrics support, allowing users to monitor system performance using their analytics tools and metrics.   

pygraphistry: 

  • Is a Python-based library to visualize large and complex datasets in interactive and visually appealing methods. 
  • Offers a graph-based visualization of data which is useful for visualizing connections and relationships between data points.  
  • Can be deployed to the cloud, allowing users to access their visualizations from anywhere.   

grafanalib: 

  • Is a Python library for programmatically creating dashboards in Grafana, an open source platform for monitoring and analytics.   
  • Allows developers to create and manage dashboards using Python code which can be version-controlled and automated.  
  • Supports macros and templates, allowing developers to create reusable components for their dashboards. 

flow-dashboard: 

  • Is designed to be used with the Flow framework, a web-based platform to build and deploy machine learning models.  
  • Can display data from various sources like APIs, streaming services, and databases.  
  • Offers built-in user management features allowing administrators to control access to data and dashboards. 

horizon: 

  • Is a Python library to build real-time monitoring systems and scalable dashboards.  
  • Offers real-time data processing capabilities, allowing users to filter, collect, and process data in real-time.   
  • Is designed to be highly scalable with support for distributed processing and horizontal scaling.   

graph-explorer: 

  • Is a Python-based library to build a dashboard to display data from different sources, like Prometheus, Elasticsearch, and Graphite.  
  • Allows users to create customizable dashboards with the support of various data sources and visualizations.  
  • Offers advanced querying capabilities, allowing users to filter and search data.   

django-controlcenter: 

  • Is a Python-based library to build reusable and customizable dashboards in Django-based web applications.  
  • Allows developers to create dashboards that display data from different sources like APIs, Django models, and other data sources.  
  • Offers integration with Django models, allowing developers to display data from their database in their dashboards.   

changes: 

  • Is a Python library that offers an easy-to-use interface to monitor file system events like creation, editing, and deletion.  
  • Allows developers to create applications that monitor directories and respond to real-time changes.  
  • Is a useful tool for creating applications that can monitor file system events in real-time with various integrations and features, making it suited for various use cases. 

bowtie: 

  • Is a bioinformatics software tool to align short DNA sequences to large reference genomes.   
  • Allows developers to easily create dashboards that display data from different sources like SQL databases, APIs, and CSV files.  
  • Offers support for interactive visualizations, like graphs, maps, and charts.   

socialsentiment: 

  • Is designed for sentiment analysis of social media data like comments or tweets on online platforms. 
  • Uses machine learning algorithms for classifying text as negative, positive, and neutral based on the sentiment expressed in the text. 
  • Offers a pre-trained sentiment analysis model which can be trained on a larger corpus of social media data.  

dashboard-api-python: 

  • Is a Python library for the Google Analytics Dashboard API which will allow developers to access and retrieve Google Analytics data programmatically using Python. 
  • Is designed to make it easier for developers to question and manipulate data in Google Analytics without requiring the API details or how to construct API calls. 
  • Includes creating and updating dashboards, managing data sources, and functions for querying data.  

Trending Discussions on Dashboard

Microk8s dashboard using nginx-ingress via http not working (Error: `no matches for kind "Ingress" in version "extensions/v1beta1"`)

Error: [PrivateRoute] is not a <Route> component. All component children of <Routes> must be a <Route> or <React.Fragment>

You cannot render a <Router> inside another <Router>. You should never have more than one in your app

Add Kubernetes scrape target to Prometheus instance that is NOT in Kubernetes

Using GitHub Actions to create a .env file in the workflow

How to use Private route in react-router-dom@v6

Field 'recordName' is not marked queryable - cloudkit dashboard

Custom Page Permission using Angular 11

Error while generating report in apache-jmeter-5.4.1.tgz

404 error while adding lambda trigger in cognito user pool

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:26

I have microk8s v1.22.2 running on Ubuntu 20.04.3 LTS.

Output from /etc/hosts:

1127.0.0.1 localhost
2127.0.1.1 main
3

Excerpt from microk8s status:

1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4  enabled:
5    dashboard            # The Kubernetes dashboard
6    ha-cluster           # Configure high availability on the current node
7    ingress              # Ingress controller for external access
8    metrics-server       # K8s Metrics Server for API access to service metrics
9

I checked for the running dashboard (kubectl get all --all-namespaces):

1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4  enabled:
5    dashboard            # The Kubernetes dashboard
6    ha-cluster           # Configure high availability on the current node
7    ingress              # Ingress controller for external access
8    metrics-server       # K8s Metrics Server for API access to service metrics
9NAMESPACE     NAME                                             READY   STATUS    RESTARTS   AGE
10kube-system   pod/calico-node-2jltr                            1/1     Running   0          23m
11kube-system   pod/calico-kube-controllers-f744bf684-d77hv      1/1     Running   0          23m
12kube-system   pod/metrics-server-85df567dd8-jd6gj              1/1     Running   0          22m
13kube-system   pod/kubernetes-dashboard-59699458b-pb5jb         1/1     Running   0          21m
14kube-system   pod/dashboard-metrics-scraper-58d4977855-94nsp   1/1     Running   0          21m
15ingress       pod/nginx-ingress-microk8s-controller-qf5pm      1/1     Running   0          21m
16
17NAMESPACE     NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
18default       service/kubernetes                  ClusterIP   10.152.183.1     <none>        443/TCP    23m
19kube-system   service/metrics-server              ClusterIP   10.152.183.81    <none>        443/TCP    22m
20kube-system   service/kubernetes-dashboard        ClusterIP   10.152.183.103   <none>        443/TCP    22m
21kube-system   service/dashboard-metrics-scraper   ClusterIP   10.152.183.197   <none>        8000/TCP   22m
22
23NAMESPACE     NAME                                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
24kube-system   daemonset.apps/calico-node                         1         1         1       1            1           kubernetes.io/os=linux   23m
25ingress       daemonset.apps/nginx-ingress-microk8s-controller   1         1         1       1            1           <none>                   22m
26
27NAMESPACE     NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
28kube-system   deployment.apps/calico-kube-controllers     1/1     1            1           23m
29kube-system   deployment.apps/metrics-server              1/1     1            1           22m
30kube-system   deployment.apps/kubernetes-dashboard        1/1     1            1           22m
31kube-system   deployment.apps/dashboard-metrics-scraper   1/1     1            1           22m
32
33NAMESPACE     NAME                                                   DESIRED   CURRENT   READY   AGE
34kube-system   replicaset.apps/calico-kube-controllers-69d7f794d9     0         0         0       23m
35kube-system   replicaset.apps/calico-kube-controllers-f744bf684      1         1         1       23m
36kube-system   replicaset.apps/metrics-server-85df567dd8              1         1         1       22m
37kube-system   replicaset.apps/kubernetes-dashboard-59699458b         1         1         1       21m
38kube-system   replicaset.apps/dashboard-metrics-scraper-58d4977855   1         1         1       21m
39

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:

1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4  enabled:
5    dashboard            # The Kubernetes dashboard
6    ha-cluster           # Configure high availability on the current node
7    ingress              # Ingress controller for external access
8    metrics-server       # K8s Metrics Server for API access to service metrics
9NAMESPACE     NAME                                             READY   STATUS    RESTARTS   AGE
10kube-system   pod/calico-node-2jltr                            1/1     Running   0          23m
11kube-system   pod/calico-kube-controllers-f744bf684-d77hv      1/1     Running   0          23m
12kube-system   pod/metrics-server-85df567dd8-jd6gj              1/1     Running   0          22m
13kube-system   pod/kubernetes-dashboard-59699458b-pb5jb         1/1     Running   0          21m
14kube-system   pod/dashboard-metrics-scraper-58d4977855-94nsp   1/1     Running   0          21m
15ingress       pod/nginx-ingress-microk8s-controller-qf5pm      1/1     Running   0          21m
16
17NAMESPACE     NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
18default       service/kubernetes                  ClusterIP   10.152.183.1     <none>        443/TCP    23m
19kube-system   service/metrics-server              ClusterIP   10.152.183.81    <none>        443/TCP    22m
20kube-system   service/kubernetes-dashboard        ClusterIP   10.152.183.103   <none>        443/TCP    22m
21kube-system   service/dashboard-metrics-scraper   ClusterIP   10.152.183.197   <none>        8000/TCP   22m
22
23NAMESPACE     NAME                                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
24kube-system   daemonset.apps/calico-node                         1         1         1       1            1           kubernetes.io/os=linux   23m
25ingress       daemonset.apps/nginx-ingress-microk8s-controller   1         1         1       1            1           <none>                   22m
26
27NAMESPACE     NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
28kube-system   deployment.apps/calico-kube-controllers     1/1     1            1           23m
29kube-system   deployment.apps/metrics-server              1/1     1            1           22m
30kube-system   deployment.apps/kubernetes-dashboard        1/1     1            1           22m
31kube-system   deployment.apps/dashboard-metrics-scraper   1/1     1            1           22m
32
33NAMESPACE     NAME                                                   DESIRED   CURRENT   READY   AGE
34kube-system   replicaset.apps/calico-kube-controllers-69d7f794d9     0         0         0       23m
35kube-system   replicaset.apps/calico-kube-controllers-f744bf684      1         1         1       23m
36kube-system   replicaset.apps/metrics-server-85df567dd8              1         1         1       22m
37kube-system   replicaset.apps/kubernetes-dashboard-59699458b         1         1         1       21m
38kube-system   replicaset.apps/dashboard-metrics-scraper-58d4977855   1         1         1       21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42  annotations:
43    kubernetes.io/ingress.class: public
44    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
45  name: dashboard
46  namespace: kube-system
47spec:
48  rules:
49  - host: main
50    http:
51      paths:
52      - backend:
53          serviceName: kubernetes-dashboard
54          servicePort: 443
55        path: /
56

Enabling the ingress-config through kubectl apply -f ingress.yaml gave the following error:

1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4  enabled:
5    dashboard            # The Kubernetes dashboard
6    ha-cluster           # Configure high availability on the current node
7    ingress              # Ingress controller for external access
8    metrics-server       # K8s Metrics Server for API access to service metrics
9NAMESPACE     NAME                                             READY   STATUS    RESTARTS   AGE
10kube-system   pod/calico-node-2jltr                            1/1     Running   0          23m
11kube-system   pod/calico-kube-controllers-f744bf684-d77hv      1/1     Running   0          23m
12kube-system   pod/metrics-server-85df567dd8-jd6gj              1/1     Running   0          22m
13kube-system   pod/kubernetes-dashboard-59699458b-pb5jb         1/1     Running   0          21m
14kube-system   pod/dashboard-metrics-scraper-58d4977855-94nsp   1/1     Running   0          21m
15ingress       pod/nginx-ingress-microk8s-controller-qf5pm      1/1     Running   0          21m
16
17NAMESPACE     NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
18default       service/kubernetes                  ClusterIP   10.152.183.1     <none>        443/TCP    23m
19kube-system   service/metrics-server              ClusterIP   10.152.183.81    <none>        443/TCP    22m
20kube-system   service/kubernetes-dashboard        ClusterIP   10.152.183.103   <none>        443/TCP    22m
21kube-system   service/dashboard-metrics-scraper   ClusterIP   10.152.183.197   <none>        8000/TCP   22m
22
23NAMESPACE     NAME                                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
24kube-system   daemonset.apps/calico-node                         1         1         1       1            1           kubernetes.io/os=linux   23m
25ingress       daemonset.apps/nginx-ingress-microk8s-controller   1         1         1       1            1           <none>                   22m
26
27NAMESPACE     NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
28kube-system   deployment.apps/calico-kube-controllers     1/1     1            1           23m
29kube-system   deployment.apps/metrics-server              1/1     1            1           22m
30kube-system   deployment.apps/kubernetes-dashboard        1/1     1            1           22m
31kube-system   deployment.apps/dashboard-metrics-scraper   1/1     1            1           22m
32
33NAMESPACE     NAME                                                   DESIRED   CURRENT   READY   AGE
34kube-system   replicaset.apps/calico-kube-controllers-69d7f794d9     0         0         0       23m
35kube-system   replicaset.apps/calico-kube-controllers-f744bf684      1         1         1       23m
36kube-system   replicaset.apps/metrics-server-85df567dd8              1         1         1       22m
37kube-system   replicaset.apps/kubernetes-dashboard-59699458b         1         1         1       21m
38kube-system   replicaset.apps/dashboard-metrics-scraper-58d4977855   1         1         1       21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42  annotations:
43    kubernetes.io/ingress.class: public
44    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
45  name: dashboard
46  namespace: kube-system
47spec:
48  rules:
49  - host: main
50    http:
51      paths:
52      - backend:
53          serviceName: kubernetes-dashboard
54          servicePort: 443
55        path: /
56error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
57

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:

1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4  enabled:
5    dashboard            # The Kubernetes dashboard
6    ha-cluster           # Configure high availability on the current node
7    ingress              # Ingress controller for external access
8    metrics-server       # K8s Metrics Server for API access to service metrics
9NAMESPACE     NAME                                             READY   STATUS    RESTARTS   AGE
10kube-system   pod/calico-node-2jltr                            1/1     Running   0          23m
11kube-system   pod/calico-kube-controllers-f744bf684-d77hv      1/1     Running   0          23m
12kube-system   pod/metrics-server-85df567dd8-jd6gj              1/1     Running   0          22m
13kube-system   pod/kubernetes-dashboard-59699458b-pb5jb         1/1     Running   0          21m
14kube-system   pod/dashboard-metrics-scraper-58d4977855-94nsp   1/1     Running   0          21m
15ingress       pod/nginx-ingress-microk8s-controller-qf5pm      1/1     Running   0          21m
16
17NAMESPACE     NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
18default       service/kubernetes                  ClusterIP   10.152.183.1     <none>        443/TCP    23m
19kube-system   service/metrics-server              ClusterIP   10.152.183.81    <none>        443/TCP    22m
20kube-system   service/kubernetes-dashboard        ClusterIP   10.152.183.103   <none>        443/TCP    22m
21kube-system   service/dashboard-metrics-scraper   ClusterIP   10.152.183.197   <none>        8000/TCP   22m
22
23NAMESPACE     NAME                                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
24kube-system   daemonset.apps/calico-node                         1         1         1       1            1           kubernetes.io/os=linux   23m
25ingress       daemonset.apps/nginx-ingress-microk8s-controller   1         1         1       1            1           <none>                   22m
26
27NAMESPACE     NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
28kube-system   deployment.apps/calico-kube-controllers     1/1     1            1           23m
29kube-system   deployment.apps/metrics-server              1/1     1            1           22m
30kube-system   deployment.apps/kubernetes-dashboard        1/1     1            1           22m
31kube-system   deployment.apps/dashboard-metrics-scraper   1/1     1            1           22m
32
33NAMESPACE     NAME                                                   DESIRED   CURRENT   READY   AGE
34kube-system   replicaset.apps/calico-kube-controllers-69d7f794d9     0         0         0       23m
35kube-system   replicaset.apps/calico-kube-controllers-f744bf684      1         1         1       23m
36kube-system   replicaset.apps/metrics-server-85df567dd8              1         1         1       22m
37kube-system   replicaset.apps/kubernetes-dashboard-59699458b         1         1         1       21m
38kube-system   replicaset.apps/dashboard-metrics-scraper-58d4977855   1         1         1       21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42  annotations:
43    kubernetes.io/ingress.class: public
44    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
45  name: dashboard
46  namespace: kube-system
47spec:
48  rules:
49  - host: main
50    http:
51      paths:
52      - backend:
53          serviceName: kubernetes-dashboard
54          servicePort: 443
55        path: /
56error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
57apiVersion: networking.k8s.io/v1
58kind: Ingress
59metadata:
60  name: dashboard
61  namespace: kube-system
62spec:
63  rules:
64  - http:
65      paths:
66      - path: /dashboard
67        pathType: Prefix
68        backend:
69          service:
70            name: kubernetes-dashboard
71            port:
72              number: 443
73

Applying this works. Also, the ingress rule gets created.

1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4  enabled:
5    dashboard            # The Kubernetes dashboard
6    ha-cluster           # Configure high availability on the current node
7    ingress              # Ingress controller for external access
8    metrics-server       # K8s Metrics Server for API access to service metrics
9NAMESPACE     NAME                                             READY   STATUS    RESTARTS   AGE
10kube-system   pod/calico-node-2jltr                            1/1     Running   0          23m
11kube-system   pod/calico-kube-controllers-f744bf684-d77hv      1/1     Running   0          23m
12kube-system   pod/metrics-server-85df567dd8-jd6gj              1/1     Running   0          22m
13kube-system   pod/kubernetes-dashboard-59699458b-pb5jb         1/1     Running   0          21m
14kube-system   pod/dashboard-metrics-scraper-58d4977855-94nsp   1/1     Running   0          21m
15ingress       pod/nginx-ingress-microk8s-controller-qf5pm      1/1     Running   0          21m
16
17NAMESPACE     NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
18default       service/kubernetes                  ClusterIP   10.152.183.1     <none>        443/TCP    23m
19kube-system   service/metrics-server              ClusterIP   10.152.183.81    <none>        443/TCP    22m
20kube-system   service/kubernetes-dashboard        ClusterIP   10.152.183.103   <none>        443/TCP    22m
21kube-system   service/dashboard-metrics-scraper   ClusterIP   10.152.183.197   <none>        8000/TCP   22m
22
23NAMESPACE     NAME                                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
24kube-system   daemonset.apps/calico-node                         1         1         1       1            1           kubernetes.io/os=linux   23m
25ingress       daemonset.apps/nginx-ingress-microk8s-controller   1         1         1       1            1           <none>                   22m
26
27NAMESPACE     NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
28kube-system   deployment.apps/calico-kube-controllers     1/1     1            1           23m
29kube-system   deployment.apps/metrics-server              1/1     1            1           22m
30kube-system   deployment.apps/kubernetes-dashboard        1/1     1            1           22m
31kube-system   deployment.apps/dashboard-metrics-scraper   1/1     1            1           22m
32
33NAMESPACE     NAME                                                   DESIRED   CURRENT   READY   AGE
34kube-system   replicaset.apps/calico-kube-controllers-69d7f794d9     0         0         0       23m
35kube-system   replicaset.apps/calico-kube-controllers-f744bf684      1         1         1       23m
36kube-system   replicaset.apps/metrics-server-85df567dd8              1         1         1       22m
37kube-system   replicaset.apps/kubernetes-dashboard-59699458b         1         1         1       21m
38kube-system   replicaset.apps/dashboard-metrics-scraper-58d4977855   1         1         1       21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42  annotations:
43    kubernetes.io/ingress.class: public
44    nginx.ingress.kubernetes.io/backend-protocol: "HTTPS"
45  name: dashboard
46  namespace: kube-system
47spec:
48  rules:
49  - host: main
50    http:
51      paths:
52      - backend:
53          serviceName: kubernetes-dashboard
54          servicePort: 443
55        path: /
56error: unable to recognize "ingress.yaml": no matches for kind "Ingress" in version "extensions/v1beta1"
57apiVersion: networking.k8s.io/v1
58kind: Ingress
59metadata:
60  name: dashboard
61  namespace: kube-system
62spec:
63  rules:
64  - http:
65      paths:
66      - path: /dashboard
67        pathType: Prefix
68        backend:
69          service:
70            name: kubernetes-dashboard
71            port:
72              number: 443
73NAMESPACE     NAME        CLASS    HOSTS   ADDRESS     PORTS   AGE
74kube-system   dashboard   public   *       127.0.0.1   80      11m
75

However, when I access the dashboard through http://<ip-of-kubernetes-master>/dashboard, I get a 400 error.

Log from the ingress controller:

1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4  enabled:
5    dashboard            # The Kubernetes dashboard
6    ha-cluster           # Configure high availability on the current node
7    ingress              # Ingress controller for external access
8    metrics-server       # K8s Metrics Server for API access to service metrics
9NAMESPACE     NAME                                             READY   STATUS    RESTARTS   AGE
10kube-system   pod/calico-node-2jltr                            1/1     Running   0          23m
11kube-system   pod/calico-kube-controllers-f744bf684-d77hv      1/1     Running   0          23m
12kube-system   pod/metrics-server-85df567dd8-jd6gj              1/1     Running   0          22m
13kube-system   pod/kubernetes-dashboard-59699458b-pb5jb         1/1     Running   0          21m
14kube-system   pod/dashboard-metrics-scraper-58d4977855-94nsp   1/1     Running   0          21m
15ingress       pod/nginx-ingress-microk8s-controller-qf5pm      1/1     Running   0          21m
16
17NAMESPACE     NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
18default       service/kubernetes                  ClusterIP   10.152.183.1     &lt;none&gt;        443/TCP    23m
19kube-system   service/metrics-server              ClusterIP   10.152.183.81    &lt;none&gt;        443/TCP    22m
20kube-system   service/kubernetes-dashboard        ClusterIP   10.152.183.103   &lt;none&gt;        443/TCP    22m
21kube-system   service/dashboard-metrics-scraper   ClusterIP   10.152.183.197   &lt;none&gt;        8000/TCP   22m
22
23NAMESPACE     NAME                                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
24kube-system   daemonset.apps/calico-node                         1         1         1       1            1           kubernetes.io/os=linux   23m
25ingress       daemonset.apps/nginx-ingress-microk8s-controller   1         1         1       1            1           &lt;none&gt;                   22m
26
27NAMESPACE     NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
28kube-system   deployment.apps/calico-kube-controllers     1/1     1            1           23m
29kube-system   deployment.apps/metrics-server              1/1     1            1           22m
30kube-system   deployment.apps/kubernetes-dashboard        1/1     1            1           22m
31kube-system   deployment.apps/dashboard-metrics-scraper   1/1     1            1           22m
32
33NAMESPACE     NAME                                                   DESIRED   CURRENT   READY   AGE
34kube-system   replicaset.apps/calico-kube-controllers-69d7f794d9     0         0         0       23m
35kube-system   replicaset.apps/calico-kube-controllers-f744bf684      1         1         1       23m
36kube-system   replicaset.apps/metrics-server-85df567dd8              1         1         1       22m
37kube-system   replicaset.apps/kubernetes-dashboard-59699458b         1         1         1       21m
38kube-system   replicaset.apps/dashboard-metrics-scraper-58d4977855   1         1         1       21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42  annotations:
43    kubernetes.io/ingress.class: public
44    nginx.ingress.kubernetes.io/backend-protocol: &quot;HTTPS&quot;
45  name: dashboard
46  namespace: kube-system
47spec:
48  rules:
49  - host: main
50    http:
51      paths:
52      - backend:
53          serviceName: kubernetes-dashboard
54          servicePort: 443
55        path: /
56error: unable to recognize &quot;ingress.yaml&quot;: no matches for kind &quot;Ingress&quot; in version &quot;extensions/v1beta1&quot;
57apiVersion: networking.k8s.io/v1
58kind: Ingress
59metadata:
60  name: dashboard
61  namespace: kube-system
62spec:
63  rules:
64  - http:
65      paths:
66      - path: /dashboard
67        pathType: Prefix
68        backend:
69          service:
70            name: kubernetes-dashboard
71            port:
72              number: 443
73NAMESPACE     NAME        CLASS    HOSTS   ADDRESS     PORTS   AGE
74kube-system   dashboard   public   *       127.0.0.1   80      11m
75192.168.0.123 - - [10/Oct/2021:21:38:47 +0000] &quot;GET /dashboard HTTP/1.1&quot; 400 54 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36&quot; 466 0.002 [kube-system-kubernetes-dashboard-443] [] 10.1.76.3:8443 48 0.000 400 ca0946230759edfbaaf9d94f3d5c959a
76

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:29
1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4  enabled:
5    dashboard            # The Kubernetes dashboard
6    ha-cluster           # Configure high availability on the current node
7    ingress              # Ingress controller for external access
8    metrics-server       # K8s Metrics Server for API access to service metrics
9NAMESPACE     NAME                                             READY   STATUS    RESTARTS   AGE
10kube-system   pod/calico-node-2jltr                            1/1     Running   0          23m
11kube-system   pod/calico-kube-controllers-f744bf684-d77hv      1/1     Running   0          23m
12kube-system   pod/metrics-server-85df567dd8-jd6gj              1/1     Running   0          22m
13kube-system   pod/kubernetes-dashboard-59699458b-pb5jb         1/1     Running   0          21m
14kube-system   pod/dashboard-metrics-scraper-58d4977855-94nsp   1/1     Running   0          21m
15ingress       pod/nginx-ingress-microk8s-controller-qf5pm      1/1     Running   0          21m
16
17NAMESPACE     NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
18default       service/kubernetes                  ClusterIP   10.152.183.1     &lt;none&gt;        443/TCP    23m
19kube-system   service/metrics-server              ClusterIP   10.152.183.81    &lt;none&gt;        443/TCP    22m
20kube-system   service/kubernetes-dashboard        ClusterIP   10.152.183.103   &lt;none&gt;        443/TCP    22m
21kube-system   service/dashboard-metrics-scraper   ClusterIP   10.152.183.197   &lt;none&gt;        8000/TCP   22m
22
23NAMESPACE     NAME                                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
24kube-system   daemonset.apps/calico-node                         1         1         1       1            1           kubernetes.io/os=linux   23m
25ingress       daemonset.apps/nginx-ingress-microk8s-controller   1         1         1       1            1           &lt;none&gt;                   22m
26
27NAMESPACE     NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
28kube-system   deployment.apps/calico-kube-controllers     1/1     1            1           23m
29kube-system   deployment.apps/metrics-server              1/1     1            1           22m
30kube-system   deployment.apps/kubernetes-dashboard        1/1     1            1           22m
31kube-system   deployment.apps/dashboard-metrics-scraper   1/1     1            1           22m
32
33NAMESPACE     NAME                                                   DESIRED   CURRENT   READY   AGE
34kube-system   replicaset.apps/calico-kube-controllers-69d7f794d9     0         0         0       23m
35kube-system   replicaset.apps/calico-kube-controllers-f744bf684      1         1         1       23m
36kube-system   replicaset.apps/metrics-server-85df567dd8              1         1         1       22m
37kube-system   replicaset.apps/kubernetes-dashboard-59699458b         1         1         1       21m
38kube-system   replicaset.apps/dashboard-metrics-scraper-58d4977855   1         1         1       21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42  annotations:
43    kubernetes.io/ingress.class: public
44    nginx.ingress.kubernetes.io/backend-protocol: &quot;HTTPS&quot;
45  name: dashboard
46  namespace: kube-system
47spec:
48  rules:
49  - host: main
50    http:
51      paths:
52      - backend:
53          serviceName: kubernetes-dashboard
54          servicePort: 443
55        path: /
56error: unable to recognize &quot;ingress.yaml&quot;: no matches for kind &quot;Ingress&quot; in version &quot;extensions/v1beta1&quot;
57apiVersion: networking.k8s.io/v1
58kind: Ingress
59metadata:
60  name: dashboard
61  namespace: kube-system
62spec:
63  rules:
64  - http:
65      paths:
66      - path: /dashboard
67        pathType: Prefix
68        backend:
69          service:
70            name: kubernetes-dashboard
71            port:
72              number: 443
73NAMESPACE     NAME        CLASS    HOSTS   ADDRESS     PORTS   AGE
74kube-system   dashboard   public   *       127.0.0.1   80      11m
75192.168.0.123 - - [10/Oct/2021:21:38:47 +0000] &quot;GET /dashboard HTTP/1.1&quot; 400 54 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36&quot; 466 0.002 [kube-system-kubernetes-dashboard-443] [] 10.1.76.3:8443 48 0.000 400 ca0946230759edfbaaf9d94f3d5c959a
76error: unable to recognize &quot;ingress.yaml&quot;: no matches for kind &quot;Ingress&quot; in version &quot;extensions/v1beta1&quot;
77

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 :

1127.0.0.1 localhost
2127.0.1.1 main
3addons:
4  enabled:
5    dashboard            # The Kubernetes dashboard
6    ha-cluster           # Configure high availability on the current node
7    ingress              # Ingress controller for external access
8    metrics-server       # K8s Metrics Server for API access to service metrics
9NAMESPACE     NAME                                             READY   STATUS    RESTARTS   AGE
10kube-system   pod/calico-node-2jltr                            1/1     Running   0          23m
11kube-system   pod/calico-kube-controllers-f744bf684-d77hv      1/1     Running   0          23m
12kube-system   pod/metrics-server-85df567dd8-jd6gj              1/1     Running   0          22m
13kube-system   pod/kubernetes-dashboard-59699458b-pb5jb         1/1     Running   0          21m
14kube-system   pod/dashboard-metrics-scraper-58d4977855-94nsp   1/1     Running   0          21m
15ingress       pod/nginx-ingress-microk8s-controller-qf5pm      1/1     Running   0          21m
16
17NAMESPACE     NAME                                TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)    AGE
18default       service/kubernetes                  ClusterIP   10.152.183.1     &lt;none&gt;        443/TCP    23m
19kube-system   service/metrics-server              ClusterIP   10.152.183.81    &lt;none&gt;        443/TCP    22m
20kube-system   service/kubernetes-dashboard        ClusterIP   10.152.183.103   &lt;none&gt;        443/TCP    22m
21kube-system   service/dashboard-metrics-scraper   ClusterIP   10.152.183.197   &lt;none&gt;        8000/TCP   22m
22
23NAMESPACE     NAME                                               DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR            AGE
24kube-system   daemonset.apps/calico-node                         1         1         1       1            1           kubernetes.io/os=linux   23m
25ingress       daemonset.apps/nginx-ingress-microk8s-controller   1         1         1       1            1           &lt;none&gt;                   22m
26
27NAMESPACE     NAME                                        READY   UP-TO-DATE   AVAILABLE   AGE
28kube-system   deployment.apps/calico-kube-controllers     1/1     1            1           23m
29kube-system   deployment.apps/metrics-server              1/1     1            1           22m
30kube-system   deployment.apps/kubernetes-dashboard        1/1     1            1           22m
31kube-system   deployment.apps/dashboard-metrics-scraper   1/1     1            1           22m
32
33NAMESPACE     NAME                                                   DESIRED   CURRENT   READY   AGE
34kube-system   replicaset.apps/calico-kube-controllers-69d7f794d9     0         0         0       23m
35kube-system   replicaset.apps/calico-kube-controllers-f744bf684      1         1         1       23m
36kube-system   replicaset.apps/metrics-server-85df567dd8              1         1         1       22m
37kube-system   replicaset.apps/kubernetes-dashboard-59699458b         1         1         1       21m
38kube-system   replicaset.apps/dashboard-metrics-scraper-58d4977855   1         1         1       21m
39apiVersion: extensions/v1beta1
40kind: Ingress
41metadata:
42  annotations:
43    kubernetes.io/ingress.class: public
44    nginx.ingress.kubernetes.io/backend-protocol: &quot;HTTPS&quot;
45  name: dashboard
46  namespace: kube-system
47spec:
48  rules:
49  - host: main
50    http:
51      paths:
52      - backend:
53          serviceName: kubernetes-dashboard
54          servicePort: 443
55        path: /
56error: unable to recognize &quot;ingress.yaml&quot;: no matches for kind &quot;Ingress&quot; in version &quot;extensions/v1beta1&quot;
57apiVersion: networking.k8s.io/v1
58kind: Ingress
59metadata:
60  name: dashboard
61  namespace: kube-system
62spec:
63  rules:
64  - http:
65      paths:
66      - path: /dashboard
67        pathType: Prefix
68        backend:
69          service:
70            name: kubernetes-dashboard
71            port:
72              number: 443
73NAMESPACE     NAME        CLASS    HOSTS   ADDRESS     PORTS   AGE
74kube-system   dashboard   public   *       127.0.0.1   80      11m
75192.168.0.123 - - [10/Oct/2021:21:38:47 +0000] &quot;GET /dashboard HTTP/1.1&quot; 400 54 &quot;-&quot; &quot;Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.71 Safari/537.36&quot; 466 0.002 [kube-system-kubernetes-dashboard-443] [] 10.1.76.3:8443 48 0.000 400 ca0946230759edfbaaf9d94f3d5c959a
76error: unable to recognize &quot;ingress.yaml&quot;: no matches for kind &quot;Ingress&quot; in version &quot;extensions/v1beta1&quot;
77apiVersion: networking.k8s.io/v1
78kind: Ingress
79metadata:
80  name: minimal-ingress
81  annotations:
82    nginx.ingress.kubernetes.io/rewrite-target: /
83spec:
84  rules:
85  - http:
86      paths:
87      - path: /testpath
88        pathType: Prefix
89        backend:
90          service:
91            name: test
92            port:
93              number: 80
94

Source https://stackoverflow.com/questions/69517855

QUESTION

Error: [PrivateRoute] is not a &lt;Route&gt; component. All component children of &lt;Routes&gt; must be a &lt;Route&gt; or &lt;React.Fragment&gt;

Asked 2022-Mar-24 at 16:08

I'm using React Router v6 and am creating private routes for my application.

In file PrivateRoute.js, I've the code

1import React from 'react';
2import {Route,Navigate} from &quot;react-router-dom&quot;;
3import {isauth}  from 'auth'
4
5function PrivateRoute({ element, path }) {
6  const authed = isauth() // isauth() returns true or false based on localStorage
7  const ele = authed === true ? element : &lt;Navigate to=&quot;/Home&quot;  /&gt;;
8  return &lt;Route path={path} element={ele} /&gt;;
9}
10
11export default PrivateRoute
12

And in file route.js I've written as:

1import React from 'react';
2import {Route,Navigate} from &quot;react-router-dom&quot;;
3import {isauth}  from 'auth'
4
5function PrivateRoute({ element, path }) {
6  const authed = isauth() // isauth() returns true or false based on localStorage
7  const ele = authed === true ? element : &lt;Navigate to=&quot;/Home&quot;  /&gt;;
8  return &lt;Route path={path} element={ele} /&gt;;
9}
10
11export default PrivateRoute
12 ...
13&lt;PrivateRoute exact path=&quot;/&quot; element={&lt;Dashboard/&gt;}/&gt;
14&lt;Route exact path=&quot;/home&quot; element={&lt;Home/&gt;}/&gt;
15

I've gone through the same example React-router Auth Example - StackBlitz, file App.tsx

Is there something I'm missing?

ANSWER

Answered 2021-Nov-12 at 21:20

I ran into the same issue today and came up with the following solution based on this very helpful article by Andrew Luca

In PrivateRoute.js:

1import React from 'react';
2import {Route,Navigate} from &quot;react-router-dom&quot;;
3import {isauth}  from 'auth'
4
5function PrivateRoute({ element, path }) {
6  const authed = isauth() // isauth() returns true or false based on localStorage
7  const ele = authed === true ? element : &lt;Navigate to=&quot;/Home&quot;  /&gt;;
8  return &lt;Route path={path} element={ele} /&gt;;
9}
10
11export default PrivateRoute
12 ...
13&lt;PrivateRoute exact path=&quot;/&quot; element={&lt;Dashboard/&gt;}/&gt;
14&lt;Route exact path=&quot;/home&quot; element={&lt;Home/&gt;}/&gt;
15import React from 'react';
16import { Navigate, Outlet } from 'react-router-dom';
17
18const PrivateRoute = () =&gt; {
19    const auth = null; // determine if authorized, from context or however you're doing it
20
21    // If authorized, return an outlet that will render child elements
22    // If not, return element that will navigate to login page
23    return auth ? &lt;Outlet /&gt; : &lt;Navigate to=&quot;/login&quot; /&gt;;
24}
25

In App.js (I've left in some other pages as examples):

1import React from 'react';
2import {Route,Navigate} from &quot;react-router-dom&quot;;
3import {isauth}  from 'auth'
4
5function PrivateRoute({ element, path }) {
6  const authed = isauth() // isauth() returns true or false based on localStorage
7  const ele = authed === true ? element : &lt;Navigate to=&quot;/Home&quot;  /&gt;;
8  return &lt;Route path={path} element={ele} /&gt;;
9}
10
11export default PrivateRoute
12 ...
13&lt;PrivateRoute exact path=&quot;/&quot; element={&lt;Dashboard/&gt;}/&gt;
14&lt;Route exact path=&quot;/home&quot; element={&lt;Home/&gt;}/&gt;
15import React from 'react';
16import { Navigate, Outlet } from 'react-router-dom';
17
18const PrivateRoute = () =&gt; {
19    const auth = null; // determine if authorized, from context or however you're doing it
20
21    // If authorized, return an outlet that will render child elements
22    // If not, return element that will navigate to login page
23    return auth ? &lt;Outlet /&gt; : &lt;Navigate to=&quot;/login&quot; /&gt;;
24}
25import './App.css';
26import React, {Fragment} from 'react';
27import {BrowserRouter as Router, Route, Routes} from 'react-router-dom';
28import Navbar from './components/layout/Navbar';
29import Home from './components/pages/Home';
30import Register from './components/auth/Register'
31import Login from './components/auth/Login';
32import PrivateRoute from './components/routing/PrivateRoute';
33
34const App = () =&gt; {
35  return (
36    &lt;Router&gt;
37      &lt;Fragment&gt;
38        &lt;Navbar/&gt;
39        &lt;Routes&gt;
40          &lt;Route exact path='/' element={&lt;PrivateRoute/&gt;}&gt;
41            &lt;Route exact path='/' element={&lt;Home/&gt;}/&gt;
42          &lt;/Route&gt;
43          &lt;Route exact path='/register' element={&lt;Register/&gt;}/&gt;
44          &lt;Route exact path='/login' element={&lt;Login/&gt;}/&gt;
45        &lt;/Routes&gt;
46      &lt;/Fragment&gt;
47    &lt;/Router&gt;
48    
49  );
50}
51

In the above routing, this is the private route:

1import React from 'react';
2import {Route,Navigate} from &quot;react-router-dom&quot;;
3import {isauth}  from 'auth'
4
5function PrivateRoute({ element, path }) {
6  const authed = isauth() // isauth() returns true or false based on localStorage
7  const ele = authed === true ? element : &lt;Navigate to=&quot;/Home&quot;  /&gt;;
8  return &lt;Route path={path} element={ele} /&gt;;
9}
10
11export default PrivateRoute
12 ...
13&lt;PrivateRoute exact path=&quot;/&quot; element={&lt;Dashboard/&gt;}/&gt;
14&lt;Route exact path=&quot;/home&quot; element={&lt;Home/&gt;}/&gt;
15import React from 'react';
16import { Navigate, Outlet } from 'react-router-dom';
17
18const PrivateRoute = () =&gt; {
19    const auth = null; // determine if authorized, from context or however you're doing it
20
21    // If authorized, return an outlet that will render child elements
22    // If not, return element that will navigate to login page
23    return auth ? &lt;Outlet /&gt; : &lt;Navigate to=&quot;/login&quot; /&gt;;
24}
25import './App.css';
26import React, {Fragment} from 'react';
27import {BrowserRouter as Router, Route, Routes} from 'react-router-dom';
28import Navbar from './components/layout/Navbar';
29import Home from './components/pages/Home';
30import Register from './components/auth/Register'
31import Login from './components/auth/Login';
32import PrivateRoute from './components/routing/PrivateRoute';
33
34const App = () =&gt; {
35  return (
36    &lt;Router&gt;
37      &lt;Fragment&gt;
38        &lt;Navbar/&gt;
39        &lt;Routes&gt;
40          &lt;Route exact path='/' element={&lt;PrivateRoute/&gt;}&gt;
41            &lt;Route exact path='/' element={&lt;Home/&gt;}/&gt;
42          &lt;/Route&gt;
43          &lt;Route exact path='/register' element={&lt;Register/&gt;}/&gt;
44          &lt;Route exact path='/login' element={&lt;Login/&gt;}/&gt;
45        &lt;/Routes&gt;
46      &lt;/Fragment&gt;
47    &lt;/Router&gt;
48    
49  );
50}
51&lt;Route exact path='/' element={&lt;PrivateRoute/&gt;}&gt;
52      &lt;Route exact path='/' element={&lt;Home/&gt;}/&gt;
53&lt;/Route&gt;
54

If authorization is successful, the element will show. Otherwise, it will navigate to the login page.

Source https://stackoverflow.com/questions/69864165

QUESTION

You cannot render a &lt;Router&gt; inside another &lt;Router&gt;. You should never have more than one in your app

Asked 2022-Mar-21 at 07:09
1import { BrowserRouter, Routes, Route } from &quot;react-router-dom&quot;;
2
3//Layouts
4import HomeLayoutRoute from &quot;./components/layouts/HomeLayout&quot;;
5
6//components
7import Home from './components/Home';
8//import Dashboard from './components/Dash';
9
10// Routing
11import PrivateRoute from &quot;./components/routing/PrivateRoute&quot;;
12
13// Screens
14import PrivateScreen from &quot;./components/loginscreens/PrivateScreen&quot;;
15import LoginScreen from &quot;./components/loginscreens/LoginScreen&quot;;
16import RegisterScreen from &quot;./components/loginscreens/RegisterScreen&quot;;
17import ForgotPasswordScreen from &quot;./components/loginscreens/ForgotPasswordScreen&quot;;
18import ResetPasswordScreen from &quot;./components/loginscreens/ResetPasswordScreen&quot;;
19
20const App = () =&gt; {
21  return (
22    &lt;BrowserRouter&gt;
23      &lt;div className=&quot;app&quot;&gt;
24        &lt;Routes&gt; 
25          &lt;HomeLayoutRoute path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;
26          &lt;PrivateRoute path=&quot;/&quot; element={&lt;PrivateScreen/&gt;} /&gt;
27          &lt;Route path=&quot;/login&quot; element={&lt;LoginScreen/&gt;} /&gt;
28          &lt;Route path=&quot;/register&quot; element={&lt;RegisterScreen/&gt;} /&gt;
29          &lt;Route path=&quot;/forgotpassword&quot; element={&lt;ForgotPasswordScreen/&gt;}/&gt;
30          &lt;Route path=&quot;/passwordreset/:resetToken&quot; element={&lt;ResetPasswordScreen/&gt;}/&gt;
31        &lt;/Routes&gt;
32      &lt;/div&gt;
33    &lt;/BrowserRouter&gt;
34  );
35};
36
37export default App;
38

This is my App.js file This is the Error : Error: You cannot render a inside another . You should never have more than one in your app.

This code works with React-Router-Dom Version 5, But When I move to React-Router-Dom version 6 this error came.

ANSWER

Answered 2021-Nov-03 at 16:48
1import { BrowserRouter, Routes, Route } from &quot;react-router-dom&quot;;
2
3//Layouts
4import HomeLayoutRoute from &quot;./components/layouts/HomeLayout&quot;;
5
6//components
7import Home from './components/Home';
8//import Dashboard from './components/Dash';
9
10// Routing
11import PrivateRoute from &quot;./components/routing/PrivateRoute&quot;;
12
13// Screens
14import PrivateScreen from &quot;./components/loginscreens/PrivateScreen&quot;;
15import LoginScreen from &quot;./components/loginscreens/LoginScreen&quot;;
16import RegisterScreen from &quot;./components/loginscreens/RegisterScreen&quot;;
17import ForgotPasswordScreen from &quot;./components/loginscreens/ForgotPasswordScreen&quot;;
18import ResetPasswordScreen from &quot;./components/loginscreens/ResetPasswordScreen&quot;;
19
20const App = () =&gt; {
21  return (
22    &lt;BrowserRouter&gt;
23      &lt;div className=&quot;app&quot;&gt;
24        &lt;Routes&gt; 
25          &lt;HomeLayoutRoute path=&quot;/&quot; element={&lt;Home /&gt;} /&gt;
26          &lt;PrivateRoute path=&quot;/&quot; element={&lt;PrivateScreen/&gt;} /&gt;
27          &lt;Route path=&quot;/login&quot; element={&lt;LoginScreen/&gt;} /&gt;
28          &lt;Route path=&quot;/register&quot; element={&lt;RegisterScreen/&gt;} /&gt;
29          &lt;Route path=&quot;/forgotpassword&quot; element={&lt;ForgotPasswordScreen/&gt;}/&gt;
30          &lt;Route path=&quot;/passwordreset/:resetToken&quot; element={&lt;ResetPasswordScreen/&gt;}/&gt;
31        &lt;/Routes&gt;
32      &lt;/div&gt;
33    &lt;/BrowserRouter&gt;
34  );
35};
36
37export default App;
38import { BrowserRouter as Router, Routes, Route } from &quot;react-router-dom&quot;;
39
40//Layouts
41import HomeLayoutRoute from &quot;./components/layouts/HomeLayout&quot;;
42
43//components
44import Home from './components/Home';
45//import Dash from './components/DashBoard';
46
47// Routing
48import PrivateRoute from &quot;./components/routing/PrivateRoute&quot;;
49
50// Screens
51import PrivateScreen from &quot;./components/loginscreens/PrivateScreen&quot;;
52import LoginScreen from &quot;./components/loginscreens/LoginScreen&quot;;
53import RegisterScreen from &quot;./components/loginscreens/RegisterScreen&quot;;
54import ForgotPasswordScreen from &quot;./components/loginscreens/ForgotPasswordScreen&quot;;
55import ResetPasswordScreen from &quot;./components/loginscreens/ResetPasswordScreen&quot;;
56
57
58const App = () =&gt; {
59  return (
60    &lt;Router&gt;
61      &lt;div className=&quot;app&quot;&gt;
62        &lt;Routes&gt;
63          &lt;HomeLayoutRoute exact path=&quot;/&quot; component={Home} /&gt;
64          &lt;PrivateRoute exact path=&quot;/&quot; component={PrivateScreen} /&gt;
65          &lt;Route exact path=&quot;/login&quot; component={LoginScreen} /&gt;
66          &lt;Route exact path=&quot;/register&quot; component={RegisterScreen} /&gt;
67          &lt;Route
68            exact
69            path=&quot;/forgotpassword&quot;
70            component={ForgotPasswordScreen}
71          /&gt;
72          &lt;Route
73            exact
74            path=&quot;/passwordreset/:resetToken&quot;
75            component={ResetPasswordScreen}
76          /&gt;
77        &lt;/Routes&gt;
78      &lt;/div&gt;
79    &lt;/Router&gt;
80  );
81};
82
83export default App;
84

This is the Code I have used with React-Router-Dom Version 5 I think problem with the Version 6

Source https://stackoverflow.com/questions/69828516

QUESTION

Add Kubernetes scrape target to Prometheus instance that is NOT in Kubernetes

Asked 2022-Feb-13 at 20:24

I run prometheus locally as http://localhost:9090/targets with

1docker run --name prometheus -d -p 127.0.0.1:9090:9090 prom/prometheus
2

and want to connect it to several Kubernetes (cluster) instances we have. See that scraping works, try Grafana dashboards etc.

And then I'll do the same on dedicated server that will be specially for monitoring. However all googling gives me all different ways to configure prometheus that is already within one Kubernetes instance, and no way to read metrics from external Kubernetes.

How to add Kubernetes scrape target to Prometheus instance that is NOT in Kubernetes?


I have read Where Kubernetes metrics come from and checked that my (first) Kubernetes cluster has the Metrics Server.

1docker run --name prometheus -d -p 127.0.0.1:9090:9090 prom/prometheus
2kubectl get pods --all-namespaces | grep metrics-server 
3

There is definitely no sense to add Prometheus instance into every Kubernetes (cluster) instance. One Prometheus must be able to read metrics from many Kubernetes clusters and every node within them.

P.S. Some old question has answer to install Prometheus in every Kubernetes and then use federation, that is just opposite from what I am looking for.

P.P.S. It is also strange for me, why Kubernetes and Prometheus that are #1 and #2 projects from Cloud Native Foundation don't have simple "add Kubernetes target in Prometheus" button or simple step.

ANSWER

Answered 2021-Dec-28 at 08:33

There are many agents capable of saving metrics collected in k8s to remote Prometheus server outside the cluster, example Prometheus itself now support agent mode, exporter from Opentelemetry, or using managed Prometheus etc.

Source https://stackoverflow.com/questions/70457308

QUESTION

Using GitHub Actions to create a .env file in the workflow

Asked 2022-Jan-28 at 15:36

I recently created this post trying to figure out how to reference GitHub Secrets in a GitHub action. I believe I got that solved & figured out and I'm onto a different issue.

Below is a sample of the workflow code as of right now, the issue I need help with is the Create and populate .Renviron file part.

1on: [push, pull_request]
2name: CI-CD
3jobs:
4  CI-CD:
5    runs-on: ${{ matrix.config.os }}
6
7    name: ${{ matrix.config.os }} (${{ matrix.config.r }})
8
9    strategy:
10      # we keep a matrix for convenience, but we would typically just run on one
11      # single OS and R version, aligned with the target deployment environment
12      matrix:
13        config:
14          - {os: ubuntu-20.04, r: 'release', rspm: &quot;https://packagemanager.rstudio.com/cran/__linux__/focal/latest&quot;}
15
16    env:
17      # Enable RStudio Package Manager to speed up package installation
18      RSPM: ${{ matrix.config.rspm }}
19      # Access token for GitHub
20      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
21
22    steps:
23
24      - name: Checkout repo
25        uses: actions/checkout@v2
26
27      - name: Setup R
28        uses: r-lib/actions/setup-r@v1
29        with:
30          r-version: ${{ matrix.config.r }}
31
32      - name: Install system dependencies
33        run: |
34          while read -r cmd
35          do
36            eval sudo $cmd
37          done &lt; &lt;(Rscript -e 'writeLines(remotes::system_requirements(&quot;ubuntu&quot;, &quot;20.04&quot;))')
38      - name: Install R dependencies
39        run: |
40          remotes::install_deps(dependencies = TRUE)
41          remotes::install_cran(&quot;rcmdcheck&quot;)
42        shell: Rscript {0}
43
44      - name: Create and populate .Renviron file
45        env:
46          AWS_HOST: ${{ secrets.AWS_HOST }}
47          AWS_PORT: ${{ secrets.AWS_PORT }}
48          AWS_PW: ${{ secrets.AWS_PW }}
49          AWS_USER: ${{ secrets.AWS_USER }}
50          DBNAME: ${{ secrets.DBNAME }}
51        run: |
52          touch .Renviron
53          echo aws_host=&quot;$AWS_HOST&quot; &gt;&gt; .Renviron
54          echo aws_port=&quot;$AWS_PORT&quot; &gt;&gt; .Renviron
55          echo aws_pw=&quot;$AWS_PW&quot; &gt;&gt; .Renviron
56          echo aws_user=&quot;$AWS_USER&quot; &gt;&gt; .Renviron
57          echo dbname=&quot;$DBNAME&quot; &gt;&gt; .Renviron
58          ls ${{ github.workspace }}
59        shell: bash
60
61      - name: Deploy to shinyapps.io
62        # continuous deployment only for pushes to the main / master branch
63        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
64        env:
65          SHINYAPPS_ACCOUNT: ${{ secrets.SHINYAPPS_ACCOUNT }}
66          SHINYAPPS_TOKEN: ${{ secrets.SHINYAPPS_TOKEN }}
67          SHINYAPPS_SECRET: ${{ secrets.SHINYAPPS_SECRET }}
68        run: Rscript deploy/deploy-shinyapps.R
69
70

I believe this .Renviron file is getting created, but I don't know where, and it certainly doesn't look like it's where the rest of the files are. I've tried a number of file path destinations, .Renviron, ~/.Renviron, $github.workspace/.Renviron, /home/runner/work/NBA-Dashboard/NBA-Dashboard/.Renviron, none of them work. After I create the file I list all of the contents of the workspace directory (which is where I want the file to be) and it's never listed there.

enter image description here

I need that .Renvrion file to be created & listed in that specific directory along with all of these other files so when I continue to the next step and use the rsconnect package to build & deploy my Shiny app it's able to include that file to retrieve environment variables correctly when someone uses the app.

I thought maybe there was some issue with .gitignore so I deleted .Renviron off of that ? But it didn't fix the issue. But ya if anyone has any ideas I'd appreciate it!

ANSWER

Answered 2021-Sep-01 at 09:23

The file is there where you expect to be

1on: [push, pull_request]
2name: CI-CD
3jobs:
4  CI-CD:
5    runs-on: ${{ matrix.config.os }}
6
7    name: ${{ matrix.config.os }} (${{ matrix.config.r }})
8
9    strategy:
10      # we keep a matrix for convenience, but we would typically just run on one
11      # single OS and R version, aligned with the target deployment environment
12      matrix:
13        config:
14          - {os: ubuntu-20.04, r: 'release', rspm: &quot;https://packagemanager.rstudio.com/cran/__linux__/focal/latest&quot;}
15
16    env:
17      # Enable RStudio Package Manager to speed up package installation
18      RSPM: ${{ matrix.config.rspm }}
19      # Access token for GitHub
20      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
21
22    steps:
23
24      - name: Checkout repo
25        uses: actions/checkout@v2
26
27      - name: Setup R
28        uses: r-lib/actions/setup-r@v1
29        with:
30          r-version: ${{ matrix.config.r }}
31
32      - name: Install system dependencies
33        run: |
34          while read -r cmd
35          do
36            eval sudo $cmd
37          done &lt; &lt;(Rscript -e 'writeLines(remotes::system_requirements(&quot;ubuntu&quot;, &quot;20.04&quot;))')
38      - name: Install R dependencies
39        run: |
40          remotes::install_deps(dependencies = TRUE)
41          remotes::install_cran(&quot;rcmdcheck&quot;)
42        shell: Rscript {0}
43
44      - name: Create and populate .Renviron file
45        env:
46          AWS_HOST: ${{ secrets.AWS_HOST }}
47          AWS_PORT: ${{ secrets.AWS_PORT }}
48          AWS_PW: ${{ secrets.AWS_PW }}
49          AWS_USER: ${{ secrets.AWS_USER }}
50          DBNAME: ${{ secrets.DBNAME }}
51        run: |
52          touch .Renviron
53          echo aws_host=&quot;$AWS_HOST&quot; &gt;&gt; .Renviron
54          echo aws_port=&quot;$AWS_PORT&quot; &gt;&gt; .Renviron
55          echo aws_pw=&quot;$AWS_PW&quot; &gt;&gt; .Renviron
56          echo aws_user=&quot;$AWS_USER&quot; &gt;&gt; .Renviron
57          echo dbname=&quot;$DBNAME&quot; &gt;&gt; .Renviron
58          ls ${{ github.workspace }}
59        shell: bash
60
61      - name: Deploy to shinyapps.io
62        # continuous deployment only for pushes to the main / master branch
63        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
64        env:
65          SHINYAPPS_ACCOUNT: ${{ secrets.SHINYAPPS_ACCOUNT }}
66          SHINYAPPS_TOKEN: ${{ secrets.SHINYAPPS_TOKEN }}
67          SHINYAPPS_SECRET: ${{ secrets.SHINYAPPS_SECRET }}
68        run: Rscript deploy/deploy-shinyapps.R
69
70      - name: Create and populate .Renviron file
71        env:
72          AWS_HOST: ${{ secrets.AWS_HOST }}
73          AWS_PORT: ${{ secrets.AWS_PORT }}
74          AWS_PW: ${{ secrets.AWS_PW }}
75          AWS_USER: ${{ secrets.AWS_USER }}
76          DBNAME: ${{ secrets.DBNAME }}
77        run: |
78          touch .Renviron
79          echo aws_host=&quot;$AWS_HOST&quot; &gt;&gt; .Renviron
80          echo aws_port=&quot;$AWS_PORT&quot; &gt;&gt; .Renviron
81          echo aws_pw=&quot;$AWS_PW&quot; &gt;&gt; .Renviron
82          echo aws_user=&quot;$AWS_USER&quot; &gt;&gt; .Renviron
83          echo dbname=&quot;$DBNAME&quot; &gt;&gt; .Renviron
84
85          echo &quot;cat .Renviron&quot;
86          cat .Renviron
87
88          echo &quot;ls -a .&quot;
89          ls -a .
90
91          echo &quot;ls -a ${{ github.workspace }}&quot;
92          ls -a ${{ github.workspace }}
93        shell: bash
94

you need to run ls -a to show hidden files.

1on: [push, pull_request]
2name: CI-CD
3jobs:
4  CI-CD:
5    runs-on: ${{ matrix.config.os }}
6
7    name: ${{ matrix.config.os }} (${{ matrix.config.r }})
8
9    strategy:
10      # we keep a matrix for convenience, but we would typically just run on one
11      # single OS and R version, aligned with the target deployment environment
12      matrix:
13        config:
14          - {os: ubuntu-20.04, r: 'release', rspm: &quot;https://packagemanager.rstudio.com/cran/__linux__/focal/latest&quot;}
15
16    env:
17      # Enable RStudio Package Manager to speed up package installation
18      RSPM: ${{ matrix.config.rspm }}
19      # Access token for GitHub
20      GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
21
22    steps:
23
24      - name: Checkout repo
25        uses: actions/checkout@v2
26
27      - name: Setup R
28        uses: r-lib/actions/setup-r@v1
29        with:
30          r-version: ${{ matrix.config.r }}
31
32      - name: Install system dependencies
33        run: |
34          while read -r cmd
35          do
36            eval sudo $cmd
37          done &lt; &lt;(Rscript -e 'writeLines(remotes::system_requirements(&quot;ubuntu&quot;, &quot;20.04&quot;))')
38      - name: Install R dependencies
39        run: |
40          remotes::install_deps(dependencies = TRUE)
41          remotes::install_cran(&quot;rcmdcheck&quot;)
42        shell: Rscript {0}
43
44      - name: Create and populate .Renviron file
45        env:
46          AWS_HOST: ${{ secrets.AWS_HOST }}
47          AWS_PORT: ${{ secrets.AWS_PORT }}
48          AWS_PW: ${{ secrets.AWS_PW }}
49          AWS_USER: ${{ secrets.AWS_USER }}
50          DBNAME: ${{ secrets.DBNAME }}
51        run: |
52          touch .Renviron
53          echo aws_host=&quot;$AWS_HOST&quot; &gt;&gt; .Renviron
54          echo aws_port=&quot;$AWS_PORT&quot; &gt;&gt; .Renviron
55          echo aws_pw=&quot;$AWS_PW&quot; &gt;&gt; .Renviron
56          echo aws_user=&quot;$AWS_USER&quot; &gt;&gt; .Renviron
57          echo dbname=&quot;$DBNAME&quot; &gt;&gt; .Renviron
58          ls ${{ github.workspace }}
59        shell: bash
60
61      - name: Deploy to shinyapps.io
62        # continuous deployment only for pushes to the main / master branch
63        if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master'
64        env:
65          SHINYAPPS_ACCOUNT: ${{ secrets.SHINYAPPS_ACCOUNT }}
66          SHINYAPPS_TOKEN: ${{ secrets.SHINYAPPS_TOKEN }}
67          SHINYAPPS_SECRET: ${{ secrets.SHINYAPPS_SECRET }}
68        run: Rscript deploy/deploy-shinyapps.R
69
70      - name: Create and populate .Renviron file
71        env:
72          AWS_HOST: ${{ secrets.AWS_HOST }}
73          AWS_PORT: ${{ secrets.AWS_PORT }}
74          AWS_PW: ${{ secrets.AWS_PW }}
75          AWS_USER: ${{ secrets.AWS_USER }}
76          DBNAME: ${{ secrets.DBNAME }}
77        run: |
78          touch .Renviron
79          echo aws_host=&quot;$AWS_HOST&quot; &gt;&gt; .Renviron
80          echo aws_port=&quot;$AWS_PORT&quot; &gt;&gt; .Renviron
81          echo aws_pw=&quot;$AWS_PW&quot; &gt;&gt; .Renviron
82          echo aws_user=&quot;$AWS_USER&quot; &gt;&gt; .Renviron
83          echo dbname=&quot;$DBNAME&quot; &gt;&gt; .Renviron
84
85          echo &quot;cat .Renviron&quot;
86          cat .Renviron
87
88          echo &quot;ls -a .&quot;
89          ls -a .
90
91          echo &quot;ls -a ${{ github.workspace }}&quot;
92          ls -a ${{ github.workspace }}
93        shell: bash
94Run touch .Renviron
95  touch .Renviron
96  echo aws_host=&quot;$AWS_HOST&quot; &gt;&gt; .Renviron
97  echo aws_port=&quot;$AWS_PORT&quot; &gt;&gt; .Renviron
98  echo aws_pw=&quot;$AWS_PW&quot; &gt;&gt; .Renviron
99  echo aws_user=&quot;$AWS_USER&quot; &gt;&gt; .Renviron
100  echo dbname=&quot;$DBNAME&quot; &gt;&gt; .Renviron
101  
102  echo &quot;cat .Renviron&quot;
103  cat .Renviron
104  
105  echo &quot;ls -a .&quot;
106  ls -a .
107  
108  echo &quot;ls -a /home/runner/work/github-actions-manual/github-actions-manual&quot;
109  ls -a /home/runner/work/github-actions-manual/github-actions-manual
110  shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0}
111  env:
112    AWS_HOST: 
113    AWS_PORT: 
114    AWS_PW: 
115    AWS_USER: 
116    DBNAME: 
117cat .Renviron
118aws_host=
119aws_port=
120aws_pw=
121aws_user=
122dbname=
123ls -a .
124.
125..
126.Renviron
127.git
128.github
129.gitignore
130LICENSE
131README.md
132change-workflow.ps1
133commit-new-workflow.ps1
134dist
135public
136test.ps1
137test2.ps1
138ls -a /home/runner/work/github-actions-manual/github-actions-manual
139.
140..
141.Renviron
142.git
143.github
144.gitignore
145LICENSE
146README.md
147change-workflow.ps1
148commit-new-workflow.ps1
149dist
150public
151test.ps1
152test2.ps1
153

Source https://stackoverflow.com/questions/69006482

QUESTION

How to use Private route in react-router-dom@v6

Asked 2022-Jan-21 at 16:10

I want to use private route with react-router-dom v6, while i am trying to apply a condition for auth.

In App.js

1&lt;Route path='/dashboard' element= { &lt;PrivateRoute&gt;&lt;Abc /&gt;&lt;/PrivateRoute&gt;}/&gt;
2

In a component .js

1&lt;Route path='/dashboard' element= { &lt;PrivateRoute&gt;&lt;Abc /&gt;&lt;/PrivateRoute&gt;}/&gt;
2&lt;Routes&gt; &lt;Route {...rest} render={props =&gt; !isAuthenticated &amp;&amp; !loading ? (&lt;Navigate to='/login' /&gt;) : (&lt;Component {...props} /&gt;)} /&gt;&lt;/Routes&gt;
3
  • When the Route is not inside <Routes> it gives an error:

Error: A <Route> is only ever to be used as the child of <Routes> element, never rendered directly. Please wrap your in a <Routes>

  • When it is inside <Routes> it give an error as:

Error: [Abc] is not a <Route> component. All component children of must be a <Route> or <React.Fragment>

Pls help me to resolve this situation ? Or any suggestion.

Tried this but one of the above error in both cases

1&lt;Route path='/dashboard' element= { &lt;PrivateRoute&gt;&lt;Abc /&gt;&lt;/PrivateRoute&gt;}/&gt;
2&lt;Routes&gt; &lt;Route {...rest} render={props =&gt; !isAuthenticated &amp;&amp; !loading ? (&lt;Navigate to='/login' /&gt;) : (&lt;Component {...props} /&gt;)} /&gt;&lt;/Routes&gt;
3&lt;Route path='/dashboard' element= {&lt;PrivateRoute&gt; &lt;Dashboard /&gt;
4         &lt;/PrivateRoute&gt;}/&gt;
5

Also

1&lt;Route path='/dashboard' element= { &lt;PrivateRoute&gt;&lt;Abc /&gt;&lt;/PrivateRoute&gt;}/&gt;
2&lt;Routes&gt; &lt;Route {...rest} render={props =&gt; !isAuthenticated &amp;&amp; !loading ? (&lt;Navigate to='/login' /&gt;) : (&lt;Component {...props} /&gt;)} /&gt;&lt;/Routes&gt;
3&lt;Route path='/dashboard' element= {&lt;PrivateRoute&gt; &lt;Dashboard /&gt;
4         &lt;/PrivateRoute&gt;}/&gt;
5`&lt;PrivateRoute path='/dashboard' element= { &lt;Dashboard /&gt;}/&gt;`
6

ANSWER

Answered 2021-Nov-11 at 07:22

In react-router-dom version 6 there is no render prop for the Route component. You can also simplify your PrivateRoute wrapper component a bit, it doesn't need to render more Routes and Route components.

Conditionally render the component's children or navigate to log in.

1&lt;Route path='/dashboard' element= { &lt;PrivateRoute&gt;&lt;Abc /&gt;&lt;/PrivateRoute&gt;}/&gt;
2&lt;Routes&gt; &lt;Route {...rest} render={props =&gt; !isAuthenticated &amp;&amp; !loading ? (&lt;Navigate to='/login' /&gt;) : (&lt;Component {...props} /&gt;)} /&gt;&lt;/Routes&gt;
3&lt;Route path='/dashboard' element= {&lt;PrivateRoute&gt; &lt;Dashboard /&gt;
4         &lt;/PrivateRoute&gt;}/&gt;
5`&lt;PrivateRoute path='/dashboard' element= { &lt;Dashboard /&gt;}/&gt;`
6const PrivateRoute = ({ auth: { isAuthenticated }, children }) =&gt; {
7  return isAuthenticated ? children : &lt;Navigate to=&quot;/login&quot; /&gt;;
8};
9

Usage:

1&lt;Route path='/dashboard' element= { &lt;PrivateRoute&gt;&lt;Abc /&gt;&lt;/PrivateRoute&gt;}/&gt;
2&lt;Routes&gt; &lt;Route {...rest} render={props =&gt; !isAuthenticated &amp;&amp; !loading ? (&lt;Navigate to='/login' /&gt;) : (&lt;Component {...props} /&gt;)} /&gt;&lt;/Routes&gt;
3&lt;Route path='/dashboard' element= {&lt;PrivateRoute&gt; &lt;Dashboard /&gt;
4         &lt;/PrivateRoute&gt;}/&gt;
5`&lt;PrivateRoute path='/dashboard' element= { &lt;Dashboard /&gt;}/&gt;`
6const PrivateRoute = ({ auth: { isAuthenticated }, children }) =&gt; {
7  return isAuthenticated ? children : &lt;Navigate to=&quot;/login&quot; /&gt;;
8};
9&lt;Route
10  path=&quot;/dashboard&quot;
11  element={
12    &lt;PrivateRoute&gt;
13      &lt;Dashboard /&gt;
14    &lt;/PrivateRoute&gt;
15  }
16/&gt;
17

A slightly improved version to allow nesting more private route components utilizes an outlet to handle rendering out nested routes.

1&lt;Route path='/dashboard' element= { &lt;PrivateRoute&gt;&lt;Abc /&gt;&lt;/PrivateRoute&gt;}/&gt;
2&lt;Routes&gt; &lt;Route {...rest} render={props =&gt; !isAuthenticated &amp;&amp; !loading ? (&lt;Navigate to='/login' /&gt;) : (&lt;Component {...props} /&gt;)} /&gt;&lt;/Routes&gt;
3&lt;Route path='/dashboard' element= {&lt;PrivateRoute&gt; &lt;Dashboard /&gt;
4         &lt;/PrivateRoute&gt;}/&gt;
5`&lt;PrivateRoute path='/dashboard' element= { &lt;Dashboard /&gt;}/&gt;`
6const PrivateRoute = ({ auth: { isAuthenticated }, children }) =&gt; {
7  return isAuthenticated ? children : &lt;Navigate to=&quot;/login&quot; /&gt;;
8};
9&lt;Route
10  path=&quot;/dashboard&quot;
11  element={
12    &lt;PrivateRoute&gt;
13      &lt;Dashboard /&gt;
14    &lt;/PrivateRoute&gt;
15  }
16/&gt;
17const PrivateWrapper = ({ auth: { isAuthenticated } }) =&gt; {
18  return isAuthenticated ? &lt;Outlet /&gt; : &lt;Navigate to=&quot;/login&quot; /&gt;;
19};
20

Usage:

1&lt;Route path='/dashboard' element= { &lt;PrivateRoute&gt;&lt;Abc /&gt;&lt;/PrivateRoute&gt;}/&gt;
2&lt;Routes&gt; &lt;Route {...rest} render={props =&gt; !isAuthenticated &amp;&amp; !loading ? (&lt;Navigate to='/login' /&gt;) : (&lt;Component {...props} /&gt;)} /&gt;&lt;/Routes&gt;
3&lt;Route path='/dashboard' element= {&lt;PrivateRoute&gt; &lt;Dashboard /&gt;
4         &lt;/PrivateRoute&gt;}/&gt;
5`&lt;PrivateRoute path='/dashboard' element= { &lt;Dashboard /&gt;}/&gt;`
6const PrivateRoute = ({ auth: { isAuthenticated }, children }) =&gt; {
7  return isAuthenticated ? children : &lt;Navigate to=&quot;/login&quot; /&gt;;
8};
9&lt;Route
10  path=&quot;/dashboard&quot;
11  element={
12    &lt;PrivateRoute&gt;
13      &lt;Dashboard /&gt;
14    &lt;/PrivateRoute&gt;
15  }
16/&gt;
17const PrivateWrapper = ({ auth: { isAuthenticated } }) =&gt; {
18  return isAuthenticated ? &lt;Outlet /&gt; : &lt;Navigate to=&quot;/login&quot; /&gt;;
19};
20&lt;Route element={&lt;PrivateWrapper /&gt;}&gt;
21  &lt;Route path=&quot;/dashboard&quot; element={&lt;Dashboard /&gt;} /&gt;
22&lt;/Route&gt;
23

Edit how-to-use-private-route-in-react-router-domv6

Source https://stackoverflow.com/questions/69923420

QUESTION

Field 'recordName' is not marked queryable - cloudkit dashboard

Asked 2022-Jan-07 at 03:51

In Cloudkit Dashboard, I select Record Type, Edit Indexes, then I select Add Basic Index. I see in the dropdown createTime, createdBy, eTag, modTime, modifiedBy, recordID and the record fields. I do not see recordName in the dropdown( Attached screenshot). Without creating index on recordName, I cannot query the record in cloudKit Dashboard. I get error: Field 'recordName' is not marked queryable How to create index on recordName? screen shot of crete index

ANSWER

Answered 2021-Oct-25 at 17:18

I ran into this same issue and solved it by adding ___recordID as a queryable index. When it is added to the list of indexes, the field changes to recordName.

To add this as a queryable index, go to the Schema Section -> Indexes, and click Add Basic Index.

Source https://stackoverflow.com/questions/69610184

QUESTION

Custom Page Permission using Angular 11

Asked 2021-Dec-31 at 09:25

I am working on an application in which I am implementing custom permission. There is subscription-based permission that I can't check in auth guard which will be static and I have implemented helper for permission which checks for route and then check it in user subscription for that route and then redirected to any of the pages on role permission. It is working fine but I need a better approach to implement it with clean code. Here is my implementation

Home Component

1import { Component, OnInit } from &quot;@angular/core&quot;;
2import { Location } from '@angular/common';   
3import { AuthService } from &quot;src/app/services/apiServices/auth.service&quot;;
4
5@Component({
6  selector: &quot;app-home&quot;,
7  templateUrl: &quot;./home.component.html&quot;
8})
9export class HomeComponent implements OnInit {
10  constructor(private readonly location: Location, private readonly authService : AuthService ) {
11  }
12  ngOnInit() {
13    this.authService.getPermission(this.location.path());
14  }
15}
16

Auth Service Code

1import { Component, OnInit } from &quot;@angular/core&quot;;
2import { Location } from '@angular/common';   
3import { AuthService } from &quot;src/app/services/apiServices/auth.service&quot;;
4
5@Component({
6  selector: &quot;app-home&quot;,
7  templateUrl: &quot;./home.component.html&quot;
8})
9export class HomeComponent implements OnInit {
10  constructor(private readonly location: Location, private readonly authService : AuthService ) {
11  }
12  ngOnInit() {
13    this.authService.getPermission(this.location.path());
14  }
15}
16getPermission(currentRoute: string) {
17    this.userPermissions = this.loggedInUserSubscriptionDetails$.subscribe(sub =&gt; {
18      if (sub) {
19        if (sub.MenuPermissioList.map(x =&gt; x.url).indexOf(currentRoute) === -1) {
20          this.router.navigate([&quot;/finance-analysis/not-authorized&quot;]);
21          return;
22        }else{
23          console.log('exists');
24        }
25      }
26    });
27
28  }
29

This code is basically getting a current location path and then checking that path in subscription MenuPermissioList if it exists then it allows to open up the page otherwise it redirected to unauthorized.

I don't want to use this code data : {roles: [ApplicationRolesEnum.CompanyAdmin]} because I have to add or remove roles from data to allow that user for a specific page and it is basically static binding. Here I have added this check and it is working fine but my permission may vary from user to user. Which makes it difficult to maintain.

1import { Component, OnInit } from &quot;@angular/core&quot;;
2import { Location } from '@angular/common';   
3import { AuthService } from &quot;src/app/services/apiServices/auth.service&quot;;
4
5@Component({
6  selector: &quot;app-home&quot;,
7  templateUrl: &quot;./home.component.html&quot;
8})
9export class HomeComponent implements OnInit {
10  constructor(private readonly location: Location, private readonly authService : AuthService ) {
11  }
12  ngOnInit() {
13    this.authService.getPermission(this.location.path());
14  }
15}
16getPermission(currentRoute: string) {
17    this.userPermissions = this.loggedInUserSubscriptionDetails$.subscribe(sub =&gt; {
18      if (sub) {
19        if (sub.MenuPermissioList.map(x =&gt; x.url).indexOf(currentRoute) === -1) {
20          this.router.navigate([&quot;/finance-analysis/not-authorized&quot;]);
21          return;
22        }else{
23          console.log('exists');
24        }
25      }
26    });
27
28  }
29     {
30        path: &quot;home&quot;,
31        canActivate: [AuthGuard, SubscriptionGuard],data : {roles: [ApplicationRolesEnum.CompanyAdmin, ApplicationRolesEnum.ExternalUser]},
32        loadChildren: () =&gt; import(&quot;src/app/pages/dashboard/dashboard.module&quot;).then(m =&gt; m.DashboardModule)
33      },
34

ANSWER

Answered 2021-Dec-31 at 09:25

You could try following approach. I did not test it now and have written it off the top of my head but it is based on an approach I used in one project.

Basically you would still use a Guard for this but load the permissions from your service dynamically and based on them either let the user activate the page or redirect to the Unauthorized page. CanActivate subscribes to the Observable for you so you don't have to manage any subscription manually.

1import { Component, OnInit } from &quot;@angular/core&quot;;
2import { Location } from '@angular/common';   
3import { AuthService } from &quot;src/app/services/apiServices/auth.service&quot;;
4
5@Component({
6  selector: &quot;app-home&quot;,
7  templateUrl: &quot;./home.component.html&quot;
8})
9export class HomeComponent implements OnInit {
10  constructor(private readonly location: Location, private readonly authService : AuthService ) {
11  }
12  ngOnInit() {
13    this.authService.getPermission(this.location.path());
14  }
15}
16getPermission(currentRoute: string) {
17    this.userPermissions = this.loggedInUserSubscriptionDetails$.subscribe(sub =&gt; {
18      if (sub) {
19        if (sub.MenuPermissioList.map(x =&gt; x.url).indexOf(currentRoute) === -1) {
20          this.router.navigate([&quot;/finance-analysis/not-authorized&quot;]);
21          return;
22        }else{
23          console.log('exists');
24        }
25      }
26    });
27
28  }
29     {
30        path: &quot;home&quot;,
31        canActivate: [AuthGuard, SubscriptionGuard],data : {roles: [ApplicationRolesEnum.CompanyAdmin, ApplicationRolesEnum.ExternalUser]},
32        loadChildren: () =&gt; import(&quot;src/app/pages/dashboard/dashboard.module&quot;).then(m =&gt; m.DashboardModule)
33      },
34import { AuthService } from &quot;src/app/services/apiServices/auth.service&quot;;
35
36
37@Injectable()
38export class SubscriptionGuard implements CanActivate {
39
40  constructor(
41    private readonly router: Router,
42    private readonly authService: AuthService,
43  ) { }
44
45  canActivate(activatedRoute: ActivatedRouteSnapshot, routerState: RouterStateSnapshot): Observable&lt;boolean&gt; {
46    return this.authService.loggedInUserSubscriptionDetails$.pipe(
47      take(1),
48      map((sub) =&gt; {
49        if (!sub) {
50          return false;
51        }
52        return sub.MenuPermissioList.map(x =&gt; x.url).includes(routerState.url);
53      }),
54      tap(hasPermission =&gt; hasPermission ? undefined : this.router.navigate(['/finance-analysis/not-authorized']))
55    );
56  }
57}
58

Edit: changed the way of extracting current url after discussion in comments.

Source https://stackoverflow.com/questions/70532429

QUESTION

Error while generating report in apache-jmeter-5.4.1.tgz

Asked 2021-Dec-31 at 08:56

sh jmeter.sh -n -t filePath.jmx -l outFilePath.jtl -e -o folderPath

1Error generating the report: org.apache.jmeter.report.dashboard.GenerationException: Error while processing samples: Consumer failed with message :Consumer failed with message :Consumer failed with message :Consumer failed with message :Begin size 0 is not equal to fixed size 5
2

In resume

1Error generating the report: org.apache.jmeter.report.dashboard.GenerationException: Error while processing samples: Consumer failed with message :Consumer failed with message :Consumer failed with message :Consumer failed with message :Begin size 0 is not equal to fixed size 5
2Consumer failed with message :Begin size 0 is not equal to fixed size 5
3
  • currently using Java version "17" 2021-09-14 LTS
  • MacOS big SUR version 11.4
  • the properties files are fresh and values are equal to the default ones
  • Jmeter 5.4.1
  • outFile.jtl
1Error generating the report: org.apache.jmeter.report.dashboard.GenerationException: Error while processing samples: Consumer failed with message :Consumer failed with message :Consumer failed with message :Consumer failed with message :Begin size 0 is not equal to fixed size 5
2Consumer failed with message :Begin size 0 is not equal to fixed size 5
3timeStamp,elapsed,label,responseCode,responseMessage,threadName,dataType,success,failureMessage,bytes,sentBytes,grpThreads,allThreads,URL,Latency,IdleTime,Connect
41632430450882,1117,HTTP Request,200,OK,FIRST_Jmeter_Test 1-3,text,true,,3824,557,3,3,Url_hidden,1111,0,256
51632430450448,1755,HTTP Request,200,OK,FIRST_Jmeter_Test 1-2,text,true,,3836,557,3,3,Url_hidden,1755,0,690
61632430450448,1755,HTTP Request,200,OK,FIRST_Jmeter_Test 1-1,text,true,,3828,557,3,3,Url_hidden,1755,0,690
71632430452312,585,HTTP Request,200,OK,FIRST_Jmeter_Test 1-2,text,true,,3836,557,3,3,Url_hidden,585,0,144
81632430452238,758,HTTP Request,200,OK,FIRST_Jmeter_Test 1-3,text,true,,3832,557,3,3,Url_hidden,757,0,137
91632430452301,806,HTTP Request,200,OK,FIRST_Jmeter_Test 1-1,text,true,,3828,557,3,3,Url_hidden,805,0,136
101632430452962,550,HTTP Request,200,OK,FIRST_Jmeter_Test 1-2,text,true,,3824,557,3,3,Url_hidden,550,0,152
111632430453328,593,HTTP Request,200,OK,FIRST_Jmeter_Test 1-1,text,true,,3828,557,2,2,Url_hidden,592,0,135
121632430453276,815,HTTP Request,200,OK,FIRST_Jmeter_Test 1-3,text,true,,3840,557,1,1,Url_hidden,814,0,142
13

The thread run successfully and the jtl file is created as well.

I quite new on Jmeter and tried to see where that "size" attribute is currently locate to see how change it, but could not find it on any *.properties file

any though how can be this fixed, what the message is referring to?

thanks

ANSWER

Answered 2021-Sep-23 at 07:18

I cannot reproduce your issue using:

  1. openjdk:8-jre-alpine docker image
  2. JMeter 5.4.1
  3. Test plan Test.jmx from extras folder of JMeter

Demo:

enter image description here

If you cannot reproduce the above behaviour I think you made some changes either to Results File Configuration or to Reporting Configuration or both so you need to inspect all the JMeter Properties which differ from the defaults and restore their values to the original ones.

If you need further support you need to share at least first 2 lines of your outFilePath.jtl results file. Better if possible the full file and all the .properties files from JMeter's "bin" folder.

Source https://stackoverflow.com/questions/69294826

QUESTION

404 error while adding lambda trigger in cognito user pool

Asked 2021-Dec-24 at 11:44

I have created a SAM template with a function in it. After deploying SAM the lambda function gets added and are also displayed while adding lambda function trigger in cognito but when I save it gives a 404 error.

SAM template

1AWSTemplateFormatVersion: '2010-09-09'
2Transform: AWS::Serverless-2016-10-31
3Description: &gt;-
4  description
5
6Globals:
7  Function:
8    CodeUri: .
9    Runtime: nodejs14.x
10
11Resources:
12  function1:
13    Type: 'AWS::Serverless::Function'
14    Properties:
15      FunctionName: function1
16      Handler: dist/handlers/fun1.handler
17

error in cognito while adding trigger

1AWSTemplateFormatVersion: '2010-09-09'
2Transform: AWS::Serverless-2016-10-31
3Description: &gt;-
4  description
5
6Globals:
7  Function:
8    CodeUri: .
9    Runtime: nodejs14.x
10
11Resources:
12  function1:
13    Type: 'AWS::Serverless::Function'
14    Properties:
15      FunctionName: function1
16      Handler: dist/handlers/fun1.handler
17[404 Not Found] Allowing Cognito to invoke lambda function cannot be completed.
18ResourceNotFoundException (Request ID: e963254b-8d2a-49fa-b012-xxxxxxxx)
19

Note - if I add a Cognito Sync trigger in the lambda config dashboard and then try to configure a trigger in the user pool it works.

ANSWER

Answered 2021-Dec-24 at 11:44

You can change to old console, set lambda trigger, it's worked. Then you can change to new console again.

Source https://stackoverflow.com/questions/70363874

Community Discussions contain sources that include Stack Exchange Network

Tutorials and Learning Resources in Dashboard

Tutorials and Learning Resources are not available at this moment for Dashboard

Share this Page

share link

Get latest updates on Dashboard