Skip to content

Commit

Permalink
Fix traefikroute-admin.yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
dviejokfs committed Oct 10, 2023
1 parent 1c2bcc7 commit f84031f
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 17 deletions.
2 changes: 1 addition & 1 deletion charts/hlf-ordnode/templates/traefikroute-admin.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ spec:
- match: HostSNI(`{{ . }}`)
services:
- name: {{ include "hlf-ordnode.fullname" $root }}
port: 7050
port: 7053
{{ end }}
tls:
passthrough: true
Expand Down
3 changes: 3 additions & 0 deletions kubectl-hlf/cmd/channel/inspect.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,11 @@ import (
"github.com/hyperledger/fabric-sdk-go/pkg/fab/resource"
"github.com/hyperledger/fabric-sdk-go/pkg/fabsdk"
"github.com/hyperledger/fabric/common/tools/protolator"
"github.com/hyperledger/fabric/protoutil"
"github.com/kfsoftware/hlf-operator/kubectl-hlf/cmd/helpers"
"github.com/spf13/cobra"
"io"
"io/ioutil"
)

type inspectChannelCmd struct {
Expand Down Expand Up @@ -56,6 +58,7 @@ func (c *inspectChannelCmd) run(out io.Writer) error {
if err != nil {
return err
}
ioutil.WriteFile("block.pb", protoutil.MarshalOrPanic(block), 0644)
cmnConfig, err := resource.ExtractConfigFromBlock(block)
if err != nil {
return err
Expand Down
52 changes: 37 additions & 15 deletions kubectl-hlf/cmd/helpers/hlf.go
Original file line number Diff line number Diff line change
Expand Up @@ -315,13 +315,15 @@ func GetCertAuthByURL(clientSet *kubernetes.Clientset, oclient *operatorv1.Clien
func GetURLForCA(certAuth *ClusterCA) (string, error) {
var host string
var port int
if len(certAuth.Spec.Istio.Hosts) > 0 {
if certAuth.Spec.Istio != nil && len(certAuth.Spec.Istio.Hosts) > 0 {
host = certAuth.Spec.Istio.Hosts[0]
port = certAuth.Spec.Istio.Port
} else if len(certAuth.Spec.GatewayApi.Hosts) > 0 {
} else if certAuth.Spec.GatewayApi != nil && len(certAuth.Spec.GatewayApi.Hosts) > 0 {
host = certAuth.Spec.GatewayApi.Hosts[0]
port = certAuth.Spec.GatewayApi.Port

} else if certAuth.Spec.Traefik != nil && len(certAuth.Spec.Traefik.Hosts) > 0 {
host = certAuth.Spec.Traefik.Hosts[0]
port = 443
} else {
client, err := GetKubeClient()
if err != nil {
Expand Down Expand Up @@ -389,14 +391,21 @@ func GetOrdererPublicURL(clientset *kubernetes.Clientset, node hlfv1alpha1.Fabri
return fmt.Sprintf("%s:%d", hostPort.Host, hostPort.Port), nil
}
func GetOrdererHostAndPort(clientset *kubernetes.Clientset, nodeSpec hlfv1alpha1.FabricOrdererNodeSpec, nodeStatus hlfv1alpha1.FabricOrdererNodeStatus) (string, int, error) {
hostName, err := utils.GetPublicIPKubernetes(clientset)
if err != nil {
return "", 0, err
}
ordererPort := nodeStatus.NodePort
if len(nodeSpec.Istio.Hosts) > 0 {
var hostName string
var err error
var ordererPort int
if nodeSpec.Istio != nil && len(nodeSpec.Istio.Hosts) > 0 {
hostName = nodeSpec.Istio.Hosts[0]
ordererPort = nodeSpec.Istio.Port
} else if nodeSpec.Traefik != nil && len(nodeSpec.Traefik.Hosts) > 0 {
hostName = nodeSpec.Traefik.Hosts[0]
ordererPort = 443
} else {
hostName, err = utils.GetPublicIPKubernetes(clientset)
if err != nil {
return "", 0, err
}
ordererPort = nodeStatus.NodePort
}
return hostName, ordererPort, nil
}
Expand All @@ -413,14 +422,21 @@ func GetPeerHostAndPort(clientset *kubernetes.Clientset, nodeSpec hlfv1alpha1.Fa
return hostName, ordererPort, nil
}
func GetOrdererAdminHostAndPort(clientset *kubernetes.Clientset, nodeSpec hlfv1alpha1.FabricOrdererNodeSpec, nodeStatus hlfv1alpha1.FabricOrdererNodeStatus) (string, int, error) {
hostName, err := utils.GetPublicIPKubernetes(clientset)
if err != nil {
return "", 0, err
}
ordererPort := nodeStatus.AdminPort
if len(nodeSpec.AdminIstio.Hosts) > 0 {
var hostName string
var err error
var ordererPort int
if nodeSpec.AdminIstio != nil && len(nodeSpec.AdminIstio.Hosts) > 0 {
hostName = nodeSpec.AdminIstio.Hosts[0]
ordererPort = nodeSpec.AdminIstio.Port
} else if nodeSpec.AdminTraefik != nil && len(nodeSpec.AdminTraefik.Hosts) > 0 {
hostName = nodeSpec.AdminTraefik.Hosts[0]
ordererPort = 443
} else {
hostName, err = utils.GetPublicIPKubernetes(clientset)
if err != nil {
return "", 0, err
}
ordererPort = nodeStatus.AdminPort
}
return hostName, ordererPort, nil
}
Expand Down Expand Up @@ -521,6 +537,12 @@ func GetCAHostPort(clientset *kubernetes.Clientset, node hlfv1alpha1.FabricCA) (
Port: node.Spec.GatewayApi.Port,
}, nil
}
if node.Spec.Traefik != nil && len(node.Spec.Traefik.Hosts) > 0 {
return &HostPort{
Host: node.Spec.Traefik.Hosts[0],
Port: 443,
}, nil
}
k8sIP, err := utils.GetPublicIPKubernetes(clientset)
if err != nil {
return nil, err
Expand Down
8 changes: 7 additions & 1 deletion kubectl-hlf/cmd/ordnode/join.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,10 +99,16 @@ func (c *joinChannelCmd) run() error {
if err != nil {
return err
}

defer chResponse.Body.Close()
log.Infof("Status code=%d", chResponse.StatusCode)
if chResponse.StatusCode != 201 {
return errors.Errorf("error joining channel, got status code=%d", chResponse.StatusCode)
errorResponse := &map[string]interface{}{}
err = json.NewDecoder(chResponse.Body).Decode(errorResponse)
if err != nil {
return err
}
return errors.Errorf("error joining channel, got status code=%d %v", chResponse.StatusCode, errorResponse)
}
chInfo := &osnadmin.ChannelInfo{}
err = json.NewDecoder(chResponse.Body).Decode(chInfo)
Expand Down

0 comments on commit f84031f

Please sign in to comment.