Skip to content

Commit

Permalink
add metrics port and new config params (#14)
Browse files Browse the repository at this point in the history
* add metrics port and new config params

* bring back kustomization
  • Loading branch information
okdas authored Mar 3, 2023
1 parent fafe4c3 commit 966a5bb
Show file tree
Hide file tree
Showing 8 changed files with 46 additions and 17 deletions.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,12 @@ spec:
- -config=/configs/config.json
- -genesis=/genesis.json
ports:
- containerPort: 8080 # +operator-builder:field:name=ports.consensus,type=int,default=8080
- containerPort: 42069 # +operator-builder:field:name=ports.consensus,type=int,default=42069
name: consensus
- containerPort: 50832 # +operator-builder:field:name=ports.rpc,type=int,default=50832
name: rpc
- containerPort: 9000 # +operator-builder:field:name=ports.metrics,type=int,default=9000
name: metrics
env:
- name: POCKET_BASE_PRIVATE_KEY
valueFrom:
Expand Down Expand Up @@ -104,14 +106,18 @@ metadata:
app: v1-validator1 # +operator-builder:field:parent=metadata.name,type=string
spec:
ports:
- port: 8080 # +operator-builder:field:name=ports.consensus,type=int,default=8080
- port: 42069 # +operator-builder:field:name=ports.consensus,type=int,default=42069
name: consensus
protocol: TCP
targetPort: consensus
- port: 50832 # +operator-builder:field:name=ports.rpc,type=int,default=50832
name: rpc
protocol: TCP
targetPort: rpc
- port: 9000 # +operator-builder:field:name=ports.metrics,type=int,default=9000
name: metrics
protocol: TCP
targetPort: metrics
selector:
app: v1-validator1 # +operator-builder:field:parent=metadata.name,type=string
---
Expand All @@ -121,20 +127,23 @@ metadata:
name: name-config # +operator-builder:field:parent=metadata.name,type=string,replace="name"
namespace: default # +operator-builder:collection:field:parent=metadata.name,type=string
data:
# +operator-builder:field:name=ports.consensus,type=int,replace="consensus_port_value",default="8080"
# +operator-builder:field:name=ports.consensus,type=int,replace="consensus_port_value",default="42069"
# +operator-builder:field:name=ports.rpc,type=int,replace="rpc_port_value",default="50832"
# +operator-builder:field:parent=metadata.name,type=string,replace="hostname_svc"
config.json: |
{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "",
"use_lib_p2p": false,
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
"timeout_msec": 5000,
"manual": true,
"debug_time_between_steps_msec": 1000
},
"private_key": ""
"private_key": "",
"server_mode_enabled": true
},
"utility": {
"max_mempool_transaction_bytes": 1073741824,
Expand All @@ -153,7 +162,8 @@ data:
"health_check_period": "5m"
},
"p2p": {
"consensus_port": consensus_port_value,
"hostname": "hostname_svc",
"port": consensus_port_value,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "",
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ We do not ship Postgres database with this operator, it is up to a user to choos

Examples can be found in the [config/samples](config/samples) directory.


## Local Development & Testing

To install the custom resource/s for this operator, make sure you have a
Expand Down
4 changes: 2 additions & 2 deletions apis/nodes/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the nodes v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=nodes.pokt.network
//+kubebuilder:object:generate=true
//+groupName=nodes.pokt.network
package v1alpha1

import (
Expand Down
3 changes: 2 additions & 1 deletion apis/nodes/v1alpha1/pocketvalidator/resources.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ spec:
prometheusScrape: false
pocketImage: "ghcr.io/pokt-network/pocket-v1:main-dev"
ports:
consensus: 8080
consensus: 42069
rpc: 50832
metrics: 9000
privateKey:
secretKeyRef:
name: "v1-validator1"
Expand Down
18 changes: 16 additions & 2 deletions apis/nodes/v1alpha1/pocketvalidator/validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ func CreateStatefulSetCollectionNameParentName(
"containerPort": parent.Spec.Ports.Rpc, // controlled by field: ports.rpc
"name": "rpc",
},
map[string]interface{}{
"containerPort": parent.Spec.Ports.Metrics, // controlled by field: ports.metrics
"name": "metrics",
},
},
"env": []interface{}{
map[string]interface{}{
Expand Down Expand Up @@ -245,6 +249,12 @@ func CreateServiceCollectionNameParentName(
"protocol": "TCP",
"targetPort": "rpc",
},
map[string]interface{}{
"port": parent.Spec.Ports.Metrics, // controlled by field: ports.metrics
"name": "metrics",
"protocol": "TCP",
"targetPort": "metrics",
},
},
"selector": map[string]interface{}{
"app": parent.Name, // controlled by field:
Expand Down Expand Up @@ -277,17 +287,20 @@ func CreateConfigMapCollectionNameParentNameConfig(
"data": map[string]interface{}{
// controlled by field: ports.consensus
// controlled by field: ports.rpc
// controlled by field:
"config.json": `{
"root_directory": "/go/src/github.com/pocket-network",
"private_key": "",
"use_lib_p2p": false,
"consensus": {
"max_mempool_bytes": 500000000,
"pacemaker_config": {
"timeout_msec": 5000,
"manual": true,
"debug_time_between_steps_msec": 1000
},
"private_key": ""
"private_key": "",
"server_mode_enabled": true
},
"utility": {
"max_mempool_transaction_bytes": 1073741824,
Expand All @@ -306,7 +319,8 @@ func CreateConfigMapCollectionNameParentNameConfig(
"health_check_period": "5m"
},
"p2p": {
"consensus_port": ` + strconv.Itoa(parent.Spec.Ports.Consensus) + `,
"hostname": "` + parent.Name + `",
"port": ` + strconv.Itoa(parent.Spec.Ports.Consensus) + `,
"use_rain_tree": true,
"is_empty_connection_type": false,
"private_key": "",
Expand Down
9 changes: 7 additions & 2 deletions apis/nodes/v1alpha1/pocketvalidator_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,20 @@ type PocketValidatorCollectionSpec struct {
}

type PocketValidatorSpecPorts struct {
// +kubebuilder:default=8080
// +kubebuilder:default=42069
// +kubebuilder:validation:Optional
// (Default: 8080)
// (Default: 42069)
Consensus int `json:"consensus,omitempty"`

// +kubebuilder:default=50832
// +kubebuilder:validation:Optional
// (Default: 50832)
Rpc int `json:"rpc,omitempty"`

// +kubebuilder:default=9000
// +kubebuilder:validation:Optional
// (Default: 9000)
Metrics int `json:"metrics,omitempty"`
}

type PocketValidatorSpecPrivateKey struct {
Expand Down
8 changes: 4 additions & 4 deletions config/manager/kustomization.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
resources:
- manager.yaml
- manager.yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
images:
- name: controller
newName: ghcr.io/pokt-network/pocket-operator
newTag: latest
- name: controller
newName: ghcr.io/pokt-network/pocket-operator
newTag: latest

0 comments on commit 966a5bb

Please sign in to comment.