func InitIpTables()

in gce-containers-startup/utils/iptables.go [34:54]


func InitIpTables() error {
        log.Print("Determining the iptables version")
        var iptables = os.Getenv("HOST_IPTABLES")
        if iptables == "" {
                return errors.New("HOST_IPTABLES environment variable is not set - cannot determine the version to be used in konlet")
        } 
        if iptables == "legacy" {
                log.Print("Detected legacy iptables on the host OS. Switching to legacy iptables.")
                var cmd = exec.Command("update-alternatives", "--set", "iptables", "/usr/sbin/iptables-legacy")

                var output, err = cmd.CombinedOutput()

                if err != nil {
                        return err
                }
                log.Printf("%s\n", output)
        } else {
                log.Print("Detected nf_tables on the host OS. Staying on the nf_tables.")
        } 
        return nil
}